How springboot Packaging Ignore Test Unit Tests

  • 2021-12-11 07:17:04
  • OfStack

springboot packaging ignores Test unit tests

Add configuration in maven pom. xml:


<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.20.1</version>
    <configuration>
        <skipTests>true</skipTests>
    </configuration>
</plugin>

spring boot Skip maven test

Every time run as is used in eclipse- > maven install always runs junit test, and some test are also associated with databases, some of which are dangerous. How do I skip testing skip test?

The spring-boot-maven-plugin plug-in already integrates the maven-surefire-plugin plug-in

It only needs to be added in pom. xml


<properties>
    <!-- maven Mode skipping maven test,  Equivalence $ mvn package -Dmaven.test.skip=true -->
    <!-- <maven.test.skip>true</maven.test.skip> -->
    <!-- surefire plugin Mode skipping maven test ,   Equivalence $ mvn package -DskipTests -->
    <skipTests>true</skipTests>
</properties>

It should be noted here that maven. test. skip skips 1 class related to test, and even. class is not generated. If junit is allowed to test, ClassNotFound errors will be found.

skipTests will compile the test class, that is, generate. class file, but instead of running the test class, you can run the test class manually.

When spring boot was not used before, maven test was skipped like this, and pom. xml was added:


<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.12.4</version>
    <configuration>
        <skipTests>true</skipTests>
    </configuration>
</plugin>

Reference: http://maven.apache.org/plugins-archives/maven-surefire-plugin-2. 12.4/examples/skipping-test.html


Related articles: