Maven skip tests with compilation errors

Is it possible to skip tests with compilation errors? Just ignore them or consider them unsuccessful?

+5
source share
4 answers

maven-compiler-pluginresponsible for compiling your tests during the phase test-compile. This plugin is configured to fail assembly if any test classes are not compiled. You can experiment with the configuration failOnError. But I doubt that you will get the expected results. The compilation process stops immediately when it encounters a compilation error. Therefore, potentially released free classes may not have been recompiled. Therefore, it will not guarantee that the files .classthat you execute during the phase testwill be “updated” with the corresponding source files .java.

  <plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <executions>
      <execution>
        <id>default-testCompile</id>
        <phase>test-compile</phase>
        <goals>
          <goal>testCompile</goal>
        </goals>
        <configuration>
          <failOnError>false</failOnError>
        </configuration>
      </execution>
    </executions>
  </plugin>
+7
source

Not recommended...

mvn -DskipTests=true clean compile

Remember that with great power comes great responsibility.

+3
source

-DskipTests . , mvn install -DskipTests.

maven - -Dmaven.test.skip=true.

Edited: It looks like it -DskipTests=truealso works!

0
source

use the following command to skip the entire test source folder. Through compilation errors in test classes, maven will not consider them if you use the following command.

mvn clean install -Dmaven.test.skip=true
0
source

All Articles