【发布时间】:2021-09-21 13:22:29
【问题描述】:
我们有一个纯 JUnit-5 项目,我们想要对我们的单元测试进行分类。
为此,我的理解是我们需要包含 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 {}
在 Intellij-Idea 中,我可以毫无问题地运行所有或仅测试套件,但使用 maven 执行时出现错误:
- 在 Intellij-Idea 中某些测试用例失败
- 在控制台上我有一个无限循环
这没有帮助:
<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>
如果我只是删除所有 XyzTestSuite.java 类,则 maven 构建成功。我也试过<exclude>my.project.domain.testsuite</exclude>。
排除接缝不起作用。为什么?
【问题讨论】:
标签: java junit junit5 maven-surefire-plugin