The failsafe plugin has four phases that it uses:
- pre-integration-test - the setup phase. use it to start a webserver or configure data in a database.
- integration-test - runs the tests.
- post-integration-test - the teardown phase. use it to stop your webserver or clean your database.
- verify - used to help intepret results of the tests. if any tests failed, the build will exit.
Configuration:
Surefire
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.7.2</version>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
Failsafe
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>failsafe-maven-plugin</artifactId>
<version>2.4.3-alpha-1</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
Another approach that I have done on previous projects is to leave all my unit tests in their appropriate projects and package all of my integration tests into a separate project that I run every few hours everyday in an integration test environment.