The Maven Failsafe Plugin is used to run integration tests. The Failsafe Plugin will not fail the build during the integration-test phase, thus enabling the post-integration-test phase to execute.
The Maven lifecycle has four phases for running integration tests:
- pre-integration-test for setting up the integration test environment.
- integration-test for running the integration tests.
- post-integration-test for tearing down the integration test environment.
- verify for checking the results of the integration tests.
The Failsafe Plugin generates reports in two different file formats:
- Plain text files (*.txt)
- XML files (*.xml)
Goals:
- failsafe:integration-test runs the integration tests of an application.
- failsafe:verify verifies that the integration tests of an application passed.
Configuration:
1. using testng.xml file: The following configuration will run your tests in parallel in 10 different threads.
<plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-failsafe-plugin</artifactId> <version>3.0.0-M4</version> <configuration> <suiteXmlFiles> <suiteXmlFile>testng.xml</suiteXmlFile> </suiteXmlFiles> <parallel>methods</parallel> <threadCount>10</threadCount> </configuration> </plugin> </plugins>
2. skipping your tests: The following configuration will skip all your tests.
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-failsafe-plugin</artifactId> <version>3.0.0-M4</version> <configuration> <skipITs>true</skipITs> </configuration> </plugin> </plugins> </build>
3. inclusions/exclusions of tests: The following configuration will include and exclude the defined tests.
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-failsafe-plugin</artifactId> <version>3.0.0-M4</version> <configuration> <includes> <include>ChromeTest.java</include> </includes> <excludes> <exclude>IETest.java</exclude> </excludes> </configuration> </plugin> </plugins> </build>