Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

maven skip tests with compilation errors

Are there an option to skip tests with compilation errors? Just ignore them or treat them as failed?

like image 596
michael nesterenko Avatar asked Nov 24 '11 09:11

michael nesterenko


People also ask

How do you skip test compilations?

To skip running the tests for a particular project, set the skipTests property to true. If you absolutely must, you can also use the maven. test. skip property to skip compiling the tests.

How do you skip the tests when running a mvn package command?

You can also skip the tests via the command line by executing the following command: mvn install -DskipTests.

Does Maven compile run tests?

Maven compiles the source code file(s) and then tests the source code file(s). Then Maven runs the test cases. Finally, Maven creates the package.

What is DskipTests in Maven?

Maven docs: -DskipTests compiles the tests, but skips running them. -Dmaven.test.skip=true skips compiling the tests and does not run them. Also this one might be important. maven.test.skip is honored by Surefire, Failsafe and the Compiler Plugin.


1 Answers

The maven-compiler-plugin is responsible for compiling your tests during the test-compile phase. This plugin is configured to fail the build if any test classes fail to compile. You could experiment with the failOnError configuration. But I doubt you'll get the results you expect. The compilation process stops immediately when it encounters a compilation error. So potentially issue free classes may not have been re-compiled. Therefore there will be no guarantee the .class files you execute during the test phase will be 'up to date' with the corresponding .java source files.

  <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>
like image 117
orien Avatar answered Sep 22 '22 07:09

orien