在JUnit5(Eclipse)中创建测试套件

5
我已经在eclipse中创建了多个测试用例的java文件,JUnit的版本是JUnit5。
现在,我正在尝试通过eclipse GUI创建一个Junit TestSuite,在创建过程中,我没有看到可用版本中的JUnit5。
这是我为创建TestSuite编写的示例代码。
import org.junit.platform.runner.JUnitPlatform;
import org.junit.platform.suite.api.IncludeClassNamePatterns;
import org.junit.platform.suite.api.IncludeEngines;
import org.junit.runner.RunWith;

@RunWith(JUnitPlatform.class)
@IncludeClassNamePatterns(".*Tests?")
@IncludeEngines("junit-jupiter")

public class AllTests {
}

这是我执行时遇到的错误。

enter image description here

我需要进行任何手动设置才能创建/运行测试套件吗?

enter image description here

2个回答

2
在使用@RunWith注释的类中执行测试时,该类在技术上是一个JUnit 4测试类。因此,在Eclipse的“运行配置”中使用“JUnit 4 Runner”来执行您的测试套件。
有关更多信息,请参见以下Eclipse错误报告:https://bugs.eclipse.org/bugs/show_bug.cgi?id=512772 如果您正在使用@RunWith(JUnitPlatform.class)来执行JUnit 5中的测试套件,则与“JUnit测试套件”对话框无关。

1
那么在JUnit5中创建测试套件的方法是什么? - techrhl
如果您正在使用@RunWith(JUnitPlatform.class),那么在JUnit 5中它技术上是一个测试套件。只是它使用JUnit 4来启动JUnit 5平台。 - Sam Brannen
请注意,我们计划为 JUnit 5 提供一流的支持套件,而无需使用 JUnit 4 _Runner_。有关详细信息,请参阅 GitHub 上标记为 suite 的所有问题:https://github.com/junit-team/junit5/issues?q=is%3Aopen+is%3Aissue+label%3A%22theme%3A+suites%22 - Sam Brannen

0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接