Maven failsafe plugin is used to run integration tests. If you only add this plugin to
integration-test phase, it won't fail the build. So you will have builds with failed integration tests. This design is to make sure the
post-integration-test phase can run and tear down the environment correctly. This is because integration tests usually involve preparing the environment (DB, file system, network, etc.) before tests run, so cleaning up is required. To check the result of integration tests,
verify phase needs to be used and fail builds correctly in this phase.
From the manual,
The Failsafe Plugin is used during the integration-test and verify phases of the build lifecycle to execute the integration tests of an application. The Failsafe Plugin will not fail the build during the integration-test phase, thus enabling the post-integration-test phase to execute.
mvn verify should be used to invoke Maven when running integration tests.
A typical example of failsafe plugin configuration should be:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-failsafe-plugin</artifactId> <version>2.18.1</version> <executions> <execution> <id>integration-test</id> <phase>integration-test</phase> <goals> <goal>integration-test</goal> </goals> </execution> <execution> <id>integration-test-verify</id> <phase>verify</phase> <goals> <goal>verify</goal> </goals> </execution> </executions> </plugin>
If you are using Atlassian Bamboo to build, make sure
**/target/failsafe-reports/*.xml is added to test results directory. Then Bamboo can correctly display integration tests results. The option Look in the standard test results directory may not work due to this bug as
**/target/failsafe-reports/*.xml is not added to the standard test results directory.