I have a JUnit 4.12 SlowTests
test suite that I want to exclude from execution unless specifically requested on the Maven command line.
I have added the following to my pom file:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
<configuration>
<excludedGroups>com.Example.SlowTests</excludedGroups>
<includes>
<include>**/*TestSuite.class</include>
</includes>
<excludes>
<exclude></exclude>
</excludes>
</configuration>
</plugin>
I have defined the category as SlowTests
and applied it to the MySlowTests
class.
I have annotated the test suite as follows:
@RunWith(Categories.class)
@IncludeCategory(SlowTests.class)
@SuiteClasses({ MySlowTests.class })
public class MySlowTestSuite
When I run mvn package
all the unit tests except MySlowTests
are executed.
However, looking at various answers such as https://stackoverflow.com/a/25639372/820657 and https://stackoverflow.com/a/21830866/820657 I expected the following command:
mvn package -Dgroups=com.Example.MySlowTests
to run the excluded MySlowTests
tests but they don't run. In fact no tests run.
What am I doing wrong?