JUnit5 tests work fine with maven but not when run through Eclipse, “No tests found with test runner 'JUnit 5'.”
我得到一个弹出窗口,标题为"无法运行测试",并显示消息"测试运行器'JUnit 5'未找到测试"。当我尝试通过
我有两个与测试相关的文件。一个是测试套件:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | ... import org.junit.jupiter.api.BeforeAll; import org.junit.platform.runner.JUnitPlatform; import org.junit.platform.suite.api.SelectPackages; import org.junit.runner.RunWith; @RunWith(JUnitPlatform.class) @SelectPackages("com.foo.stufftotest") public class TestSuite { @BeforeAll public static void setup() { ... |
另一个包含"实际"测试:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | package com.foo.stufftotest; import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; import com.foo.TestSuite; import com.foo.business.mechanics.LogicStuff1; public class BusinessTest { @Test public void testLogic1() { ... } @Test public void testLogic2() { ... } ... |
所有
但是,当我在项目上运行
我不记得JUnit 4有这个问题,尽管我从未在这个特定项目中使用JUnit 4。
我使用Eclipse是否错误,还是使用JUnit5错误?解决的方法是什么?
尽管我的单元测试已使用
我使用了
我的解决方案:
添加后,我便能够从Eclipse手动执行测试。但是我仍然不确定为什么没有自动添加。
I'm getting a pop-up window with title"Could not run test" and message"No tests found with test runner 'JUnit 5'." when I try to run JUnit 5 tests with Eclipse via
Run As > JUnit Test .
这是因为
您遇到的另一个问题是