Please refer to surefire:test for details, but the most useful properties are:
-Dmaven.test.failure.ignore=true (or -DtestFailureIgnore=true) - will ignore any failures occurred during test execution
-Dmaven.test.error.ignore=true ( deprecated ) - will ignore any errors occurred during test execution
-DskipTests - would compile the test classes but skip test execution entirely
-Dmaven.test.skip=true - would not even compile the tests
I believe that in your case where you want to compile test classes but not fail the build due to any tests errors and still create the jar.
You should use the first option to ignore any test failures which you can still review once the build has finished.
mvn -Dmaven.test.skip=true package
skips the surefire test mojo.
to ignore test failures and keep maven from stopping you can add this to the section of the pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
The solution is:
mvn -fn clean install
execute mvn --help
for advanced options
Here's the excerpt for -fn
-fn,--fail-never NEVER fail the build, regardless
of project result
<properties>
<maven.test.skip>true</maven.test.skip>
<maven.test.failure.ignore>true</maven.test.failure.ignore>
</properties>
http://jira.codehaus.org/browse/SUREFIRE-319
Or from command line
http://maven.apache.org/maven-1.x/plugins/test/properties.html
maven.test.error.ignore Yes Set this to true to ignore errors during testing. Its use is NOT RECOMMENDED, but quite convenient on occasion
Use -DskipTests=true instead of -Dmaven.test.skip=true in order to skip tests but compile them.
Using -Dmaven.test.failure.ignore=true will also work but is not very nice.
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