我在 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 {
}
这是我在执行时遇到的错误。
我应该进行任何手动设置才能创建/运行测试套件吗?
在用注释的类中执行测试时@RunWith
,该类从技术上讲是 JUnit 4 测试类。
因此,您必须使用 Eclipse 的“运行配置”中的“JUnit 4 Runner”来执行测试套件。
有关详细信息,请参阅以下 Eclipse 错误:https://bugs.eclipse.org/bugs/show_bug.cgi?id=512772 https://bugs.eclipse.org/bugs/show_bug.cgi?id=512772
关于“JUnit Test Suite”对话框,如果您使用的是@RunWith(JUnitPlatform.class)
在 JUnit 5 中执行套件。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)