What is the difference between the Maven Surefire and Maven Failsafe plugins?

bugCracker picture bugCracker · Mar 11, 2015 · Viewed 35.9k times · Source

What is the difference between Maven Surefire and Maven Failsafe plugins?
I have searched all over web, but did not get the answer.

Answer

kenorb picture kenorb · Dec 13, 2015

In simple words, the Failsafe plugin is designed to run integration tests while Surefire to run unit tests.

This is further explained in Maven FAQ:

  • maven-surefire-plugin is designed for running unit tests and if any of the tests fail then it will fail the build immediately.

  • maven-failsafe-plugin is designed for running integration tests, and decouples failing the build if there are test failures from actually running the tests.

    The name "failsafe" was chosen both because it is a synonym of surefire and because it implies that when it fails, it does so in a safe way.

    The Failsafe Plugin has two goals:

See also: