Comparison of maven-surefire-plugin and maven-failsafe-plugin

References:

Maven Failsafe Plugin: https://maven.apache.org/surefire/maven-failsafe-plugin/index.html

Maven Surefire Plugin: https://maven.apache.org/surefire/maven-surefire-plugin/index.html

Someone asked me then what is the advantage of using one over the another.

The advantage is the way they fail:

Failsafe > runs all the integration tests, but if any tests fail during the integration-test phase, the plugin does not fail the build immediately. It still executes the post-integration-test phase. Therefore we can still perform any cleanup and environment tear-down as part of the post-integration-test phase. The subsequent verify phase of the build process reports any test failures.

Surefire > It binds with the test phase, in case of any test failures, the build fails, and no further phases execute during the build process.

--

--