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

南楼画角 提交于 2019-12-29 11:30:42

问题


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


回答1:


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:

    • failsafe:integration-test runs the integration tests of an application,
    • failsafe:verify verifies that the integration tests of an application passed.

See also:

  • Benefits of Maven FailSafe Plugin at SO



回答2:


From https://maven.apache.org/surefire/maven-failsafe-plugin/, I would say that the difference between Surefire and Failsafe is the way they fail:

If you use the Surefire Plugin for running tests, then when you have a test failure, the build will stop at the integration-test phase and your integration test environment will not have been torn down correctly.

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.




回答3:


In my country its the second google result when searching for "maven failsafe maven surefire" to get to this FAQ: https://maven.apache.org/surefire/maven-failsafe-plugin/ which states:

"The Failsafe Plugin is designed to run integration tests while the Surefire Plugin is designed to run unit tests."



来源:https://stackoverflow.com/questions/28986005/what-is-the-difference-between-the-maven-surefire-and-maven-failsafe-plugins

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!