I have read here about unit testing with the Surefire plugin and integration testing with the Failsafe plugin, but I am still unclear about how the POMs should look in a Maven project that consists of a parent and multiple child modules, each with their own POM file.
Questions:
See my answer to question: How can I switch between two test suites in Maven 2? I prefer maven module - very easy to implement and you do not need knowledge about other plugin.
If you using testng you can just define in your parent pom (one place only):
<profile>
<id>normal</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludedGroups>integration</excludedGroups>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>integration</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includedGroups>integration</includedGroups>
</configuration>
</plugin>
</plugins>
</build>
</profile>
Annotate all integration tests by:
@Test(groups="integration")
If you use junit see Category
You run normal test by: mvn clean install
integration tests by mvn -Pintegration clean install