Tag Archives: test case

[Solved] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test

There is a mave aggregation project. The following error is reported when packaging through the maven command:

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test

The packaging command is as follows: clean package

Solution 1:
Click Toggle ‘Skip Tests’ mode in the maven panel in idea tools, and package it again and it works fine.
Solution 2:
Specify skipTests as true in the pom file to skip unit tests

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

Solution 3:
Execute the command at the Terminal

mvn install -DskipTests

Solution 4:
Execute the command at the Terminal

mvn install -Dmaven.test.skip=true

Solution 5:
In the springboot project, spring-boot-maven-plugin plugin has been integrated with the maven-surefire-plugin plugin, will automatically run junit test, you need to add the following configuration in the pom

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

Among them, -Dmaven.test.skip=true and -DskipTests have the following roles

  • -DskipTests: does not execute the test cases, but compiles the test case classes to generate the corresponding class files under target/test-classes.
  • -Dmaven.test.skip=true: does not execute the test cases and does not compile the test case classes.