Reputation: 4435
We have a pure JUnit-5 project and we want to categories our unit tests.
To do so, what I understand is we need to include the JUnit-4 @RunWith(JUnitPlatform.class)
.
import org.junit.platform.runner.JUnitPlatform;
import org.junit.platform.suite.api.IncludeTags;
import org.junit.platform.suite.api.SelectPackages;
import org.junit.runner.RunWith;
@RunWith(JUnitPlatform.class)
@SelectPackages("my.project.domain")
@IncludeTags("long-running-test")
public interface LongRunningTestSuite {}
In Intellij-Idea I can run all or just test suites without problems but I get an error on the execution with maven:
This didn't help:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>false</skip>
<excludes>
<exclude>**/*TestSuite.java</exclude>
</excludes>
<includes>
<include>**/*Test.java, **/*IT.java</include>
</includes>
</configuration>
</plugin>
If I just remove all the XyzTestSuite.java
classes the maven build is successful. I also tried <exclude>my.project.domain.testsuite</exclude>
.
The exclution seams not to work. Why?
Upvotes: 2
Views: 7913
Reputation: 5341
JUnitPlatform
has been deprecated.
The corresponding new feature is the JUnit Platform Suite Engine. See JUnit 5 User Guide: 6.2. JUnit Platform Suite Engine.
However, if it’s just about categorizing tests, tags, which are much simpler, might be sufficient. See JUnit 5 User Guide: 2.9 Tagging and Filtering.
Upvotes: 4