We use the "failsafe" plugin in maven to run and manage integration tests.
Usually, when you build your project, you want to skip running the integration/regression tests;
So, you 'exclude' them from the usual 'test' phase by adding this (in the xpath /pom:project/pom:build/pom:plugins/pom:plugin
) in your pom.xml
:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<excludes>
<!-- even if you wanted to run all the unit tests, do not run the regression test (since it depends on a local logfile) -->
<exclude>**/*RegressionTest.java</exclude>
</excludes>
<skipTests>${skipTests}</skipTests>
</configuration>
</plugin>
Now, add a the following section :
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.16</version>
<configuration>
<includes>
<include>**/*RegressionTest.java</include>
</includes>
</configuration>
</plugin>
You can now run the regression test by doing:
mvn clean test-compile failsafe:integration-test -DskipTests=false
To see how you can run a single test, read : https://maven.apache.org/surefire/maven-failsafe-plugin/examples/single-test.html