Below is an example of turning off maven-surefire-plugin during the "test" phase, and turning on maven-surefire-plugin for the "integration-test". The key to turning off "test" phase execution is setting skip=true for the plugin's default configuration (<skip>true</skip>).
<!-- skip unit test run, tests to be executed during integration-test -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
<executions>
<execution>
<id>surefire-it</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>false</skip>
</configuration>
</execution>
</executions>
</plugin>
|
You can change the test directory to src/it in order to mark the difference with normal tests.
<build>
<testSourceDirectory>src/it/java</testSourceDirectory>
<testResources>
<testResource>
<filtering>false</filtering>
<directory>src/it/resources</directory>
</testResource>
</testResources>
...
|
Note : You cannot have unit tests and integration tests in the same Maven project.