I have a pom.xml file having surefire:test plugin and have two profiles to run diffrent test modules/tests. Iam trying to run these by command "mvn surefire:test -PfirstProfile,secondProfile". But here only the second profile written in pom.xml gets executed. This command is recommended by apache maven website. Here is my pom.xml file:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.plugin.surefire.version}</version>
<configuration>
<forkMode>always</forkMode>
<!-- <testFailureIgnore>true</testFailureIgnore> -->
<failIfNoTests>false</failIfNoTests>
<skipTests>${skipTests}</skipTests>
<runOrder>${testRunOrder}</runOrder>
</configuration>
</execution>
</executions>
</plugin>
<profile>
<id>firstProfile</id>
<properties>
<skipTests>false</skipTests>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.plugin.surefire.version}</version>
<configuration>
<includes>
<include>**/AbcTest.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>SecondProfile</id>
<properties>
<skipTests>false</skipTests>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.plugin.surefire.version}</version>
<configuration>
<includes>
<include>**/xyzTest.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
so how do i run both these profiles together? I tried execution IDs also. But it is not working.
Try to change the configuration for maven-surefire-plugin in both profiles like this:
Apart from this it's not a good idea to select unit tests by profiles. If those tests are integration test you should go with maven-failsafe-plugin instead.