I could not find this functionality by reading the current documentation. I think it would be a good idea to have the following targets added to m2 and the surefire plugin:
test:unit
test:integration
test:functional
Currently I don't know how to separate these tests with Maven 2 beta 3. It is a good idea to separate the tests into different groups. Fast running and simple tests should be run when executing the test:unit target. Longer running should not be executed at every build just before deploy.
Surefire could look for the tests in a default location. For example something like:
src/main/test/java/**/unit/*Test.java
src/main/test/java/**/integration/*Test.java
src/main/test/java/**/functional/*Test.java
These paths could also be specified in the pom.xml.
Another possibility would be the possibility of defining your own groups in the pom. And execute them with for example m2 test:group unit.
<profiles>
<profile>
<id>unit-tests</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>**/unit/*Test.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>integration-tests</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>**/integration/*Test.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>functional-tests</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>**/functional/*Test.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>