Are there an option to skip tests with compilation errors? Just ignore them or treat them as failed?
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.
You can also skip the tests via the command line by executing the following command: mvn install -DskipTests.
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.
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.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With