Have a test method annotated with category:
public interface BVT {} //is placed in package net.test.categories, file name BVT.java
public class TestClass{
@Test
@Category(BVT.class)
public void someTest(){
System.out.println("smoke");
} }
I use Junit 4.12 and surefire 3.0.0-M3
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M3</version>
<configuration>
<forkCount>${threadCount}</forkCount>
<reuseForks>false</reuseForks>
<skip>false</skip>
<groups>${testGroup}</groups>
</configuration>
</plugin>
If I try to run test from BVT category
mvn clean test -DtestGroup="net.test.categories.BVT"
I get
[INFO] Results:
[INFO]
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
Have no ideas why the test was not run/skipped... Using of created in pom profile didn't help - it just runs all the tests. Adding this runner dependency also doesn't help:
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>3.0.0-M3</version>
</dependency>
</dependencies>
Creating a Suite runs the needed test but I don't want to list all required classes in this suite class, just want to run a certain group from command line
Didn't find reason, but adding include section in surefire configuration solved the issue.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M3</version>
<configuration>
<forkCount>${threadCount}</forkCount>
<reuseForks>false</reuseForks>
<skip>false</skip>
<groups>${testGroup}</groups>
<includes>
<include>*</include>
</includes>
</configuration>
</plugin>