I have two surefire executions in one profile – they need different config.
When I run -Dtest=…, the matching test is running twice – once for each execution.
How can I make the test run only once?
Or better, how can I make surefire follow includes and excludes?
(One execution would run 0 tests; I’d use -DfailIfNoTest=false.)
<profile>
<id>clustering.integration.tests.profile</id>
<activation>
<property>
<name>clustering.integration.tests</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<executions combine.children="append">
<!-- Disable default-test execution. -->
<execution>
<id>default-test</id>
<goals><goal>test</goal></goals>
<phase>none</phase>
</execution>
<!-- Single node clustering tests. -->
<execution>
<id>tests-clustering-single-node.surefire</id>
<phase>test</phase>
<goals><goal>test</goal></goals>
<configuration>
<includes>
<include>org/jboss/as/test/clustering/single/**/*TestCase.java</include>
</includes>
</configuration>
</execution>
<!-- Multi node clustering tests. -->
<execution>
<id>tests-clustering-multi-node.surefire</id>
<phase>test</phase>
<goals><goal>test</goal></goals>
<configuration>
<includes>
<include>org/jboss/as/test/clustering/cluster/**/*TestCase.java</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
This sounds like a misuse of the maven-surefire-plugin, cause you seemed to have some kind of integration-tests which should be done by the maven-failsafe-plugin instead. By using them you automatically have different configurations for unit- and integration tests. The maven-surefire-plugin is intended to run unit tests where as the maven-failsafe-plugin is intended to run integration tests. Furthermore you configuration looks like you need different kind of integration-tests which means in other word to have several integration-tests modules.
And this will be the best thing to have different configurations for integration test runs.