I'm running tests on a project using the surefire plugin and then need to generate a report using the "site" goal, even if there are failed tests.
The thing is that by default surefire forces the build to fail in a case of failed tests and no further goals are executed. So that I set the following configuration to surefire:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire.version}</version>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
This works well and the "site" goal is always executed, but in such a case the status of the build is always "Success" so that I can't set up emails notification.
Is there a proper way to execute the next goals after a "test" goal without ignoring the failures in the surefire plugin?
You could use:
-DskipTests=true
to skip test execution entirely-Dmaven.test.failure.ignore=true
to ignore test failures--fail-at-end
to let the build continue after the test phase and only fail (if there are test failures) when the entire build cycle is completeGiven this statement ...
This works well and the "site" goal is always executed, but in such a case the status of the build is always "Success" so that I can't set up emails notification.
... I think you want to use --fail-at-end
. According to the docs its behaviour is:
--fail-at-end - if a particular module build fails, continue the rest of the reactor and report all failed modules at the end instead
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