【问题标题】:How run test suite JUnit5-based?如何运行基于 JUnit5 的测试套件?
【发布时间】:2021-03-03 14:39:57
【问题描述】:
我想为基于 JUnit-5 的测试类创建运行器。
一开始我尝试使用这种结构。
@RunWith(JUnitPlatform.class)
@SelectClasses(UserAPITest.class)
public class UserAPITestRunner {
}
但是 in 不起作用。如果我理解正确,那么在这样的跑步者的帮助下,我可以基于 JUnit4 运行。
我们如何运行套件 JUnit5 测试?
【问题讨论】:
标签:
junit
junit4
junit5
runner
【解决方案1】:
从技术上讲,如果您使用的是 JUnit 5 中的一个套件 @RunWith(JUnitPlatform.class)。它只是使用 JUnit 4 来启动 JUnit 5 平台。
来自the documentation:
使用 @RunWith(JUnitPlatform.class) 注释的测试类和套件不能直接在 JUnit 平台上执行(或作为某些 IDE 中记录的“JUnit 5”测试)。此类类和套件只能使用 JUnit 4 基础架构执行。