Why does <excludeGroups> work, but <groups> does not?
I am trying to separate integration tests and smoke tests using @Category - JUnit annotations and profiles. So if I run mvn clean install -P smoke-tests , only Smoke-Tests will run, and if I run mvn clean install , every test will run.
The fact is that
When I exclude groups in Maven using <excludeGroups> , it excludes groups as expected. But when I try to enable them using <groups> , it still runs every test anyway. The Maven code is unremarkable:
<profile> <id>smoke-tests</id> <activation> <activeByDefault>false</activeByDefault> </activation> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-failsafe-plugin</artifactId> <version>2.12</version> <configuration> <parallel>classes</parallel> <threadCount>4</threadCount> <perCoreThreadCount>false</perCoreThreadCount> <!-- <excludeGroups>de.package.SmokeTest</excludeGroups> --> <groups>de.package.SmokeTest</groups> </configuration> <executions> <execution> <goals> <goal>integration-test</goal> <goal>verify</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </profile> Of course, I could solve this problem using <include> and <exclude> , but I would really like to use the @Category annotation.
Any help is appreciated.
This is a bug that was fixed in 2.12.1: JUnit categories only work if the junit47 provider is explicitly installed . If you cannot upgrade, specify the junit provider explicitly and it should work:
<plugin> <artifactId>maven-surefire-plugin</artifactId> <version>2.12</version> <configuration> <groups>uk.co.farwell.test.SlowTests</groups> </configuration> <dependencies> <dependency> <groupId>org.apache.maven.surefire</groupId> <artifactId>surefire-junit47</artifactId> <version>2.12</version> </dependency> </dependencies> </plugin>