How to skip tests when maven is packaged

tags: java basics  maven  java

Happening scene:

When packaging the project before, I made a mistake when packaging the test class, so I wanted to skip the test environment for packaging.

Method 1: Modify the pom file

<build>
    <plugins>
        <!--Skip tests when packaging-->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.18.1</version>
            <configuration>
                <skipTests>true</skipTests>
            </configuration>
        </plugin>
    </plugins>
</build>

Add the above plug-ins to the pom file of your own maven project, and then install and package, and the package can be successfully packaged.

Method 2: Execute commands in Terminal

mvn install -Dmaven.test.skip=true (recommended) or mvn install -DskipTests (not recommended, too slow)

Method 3: Add the following configuration in pom.xml (only applicable to springBoot projects):

Because the spring-boot-maven-plugin plug-in has integrated the maven-surefire-plugin plug-in, it will automatically run junit test

<properties>
         <!-- skip test -->
    <skipTests>true</skipTests>
</properties>

Reference blog:Skip tests when maven is packaged - Programmer Sought

Intelligent Recommendation

Skip testing when springboot (or spring) projects are packaged with maven

There are three ways to skip the test when using maven to package method one For the spring project: For springboot: Add the following information: Method three (general): Way four (general):...

Three examples of schemes that skip the test when maven packaged

Three solutions for testing test 1. Maven navigation bar operation: Cancel the life cycle, through the button of the interface! No Maven interface UI, please read this article Maven navigation bar set...

Skip test when maven is packaged, and pack the source code and documentation

SpringBoot project, skip test during packaging, and packs the Maven plug -in configuration of the source code and documentation....

How to skip unit tests spring boot when packaging

Packaged with the package maven command The default category will run the test unit tests, as shown below Packaging skip class to run test Pom modify the script, you can skip unit testing org.apache.m...

How to skip testing when packaging Maven in IDEA

Transfer from Method 1: Directly use the method provided by IDEA The toolbar of the Maven command bar has the following pictureIcon, it says Skip Tests PressAfter the icon, as shown below, test is not...

More Recommendation

How to skip the test when packaging Maven in IDEA

How to skip the test when packaging Maven in IDEA When maven is packaged, the test class will be packaged and run. If the run fails, an error will be reported. The easiest way is to skip the test. Met...

How to skip execution tests using SKIP

1, @ pytest.mark.skip (REASON = ") - Skip execution test functions It can be introduced to a non-parameter referiority. Output results: Test_fixture2.py ss --- use case c execution --- 2, @ pytes...

Gradle-how to skip unit tests

By default, if any unit test fails, the Gradle build will abort. Usually, even if the unit test fails, we still need to build the project. To skip the entire unit test in the Gradle build, use this op...

Skip the test when mvn is packaged

Add after the packaging command Or directly add configuration in pom...

Maven notes-use -DskipTests to skip unit tests

When the project was installed in the local warehouse, an Error occurred because the project lacked a certain test class and failed to pass the unit test. Finally, mvn install failed to execute. At th...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top