Archive for November, 2009

MAVEN: Tuning which tests to run …

Thursday, November 26th, 2009

On a recent project we needed to tune MAVEN to run unit tests and integration tests separately.

When we execute “mvn test” we want just our unit tests to run, and when we execute  “mvn integration-test” we want integration tests to run. Of course the unit tests will run as well because they are a dependency.

This is not as simple as it could be in MAVEN so I’m sharing the working plugin configuration with you.  Here it is:

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludes>
<exclude>**/*ITest.java</exclude>
</excludes>
</configuration>
<executions>
<execution>
<id>integration-tests</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>${integration.test.skip}</skip>
<includes>
<include>**/*ITest.java</include>
</includes>
<excludes>
<!– Ensure Maven inhierits exclude –>
<exclude>must-be-here-for-maven</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>