I read Maven Failsafe plugin is designed specifically to run integration tests. Currently I'm working on a multi-module project and integration tests are in its own separate module, written in TestNg and run using Surefire plugin. We don't have conflicts with unit tests since only integration tests are run in the test phase in that module. And to set up the environment before the tests, and clean it after tests are run, @BeforeSuite @AfterSuite
TestNg annotations are used. So there's no need to make use of pre-integration-test
phase, integration-test
phase, post-integration-test
phase utilized by Failsafe plugin.
pre-integration-test
, post-integration-test
phases without writing a maven plugin?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.
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.
Maven sure fire plugin is used to follow the sequence of tests in testng. xml file. If we don't include the Mavwen surefire plugin then it will execute all the testcases under src/test/java which has prefix or suffix as 'test' and these tests will get executed without any sequence.
The Surefire Plugin is used during the test phase of the build lifecycle to execute the unit tests of an application. It generates reports in two different file formats: Plain text files (*. txt)
If you already have your own test setup/teardown in your suites, which from the looks of it you do, there is not much you can gain from the FailSafe plugin.
The FailSafe plugin is useful in situations where the Setup of your System Under Test is costly or takes a long time such as starting up a Servlet or a distributed system. The way the FailSafe plugin comes handy in these situations is that you can set up this environment in the pre-integration-test
phase. This plugin also doesn't stop the execution of the Maven build when a test fails, which allows you to clean up all of your artifacts during the post-integration-test
phase, after which it checks the status of your tests and passes or fails the build accordingly during the verify
phase.
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