[英]JUnit 4 tests results not showing in Eclipse
我的问题是 JUnit 4 测试结果未显示在 Eclipse 中。 我已将 System.out.println("....") 添加到我的测试类中的每个 @Test 方法中,并且它们运行导致 Console 显示输出,但是,包浏览器旁边的 JUnit 选项卡未显示任何结果. 它说运行 0/0,错误 0,失败 0。
我应该补充一点,我已经添加了 JUnit 4 来构建路径。 我浏览了互联网以寻找一个小时的答案,但没有找到任何东西。 这里有什么问题? 我真的很感激任何线索!
我有同样的问题。 我尝试了所有方法,但仍然无法在 Eclipse 中显示 junit4 结果,但我认为这个问题可能是 Eclipse 错误。 我的环境是 Mac OS 11x EI 和用于 64 mac 的 Eclipse Mars,JDK 是 1.7 我在我的电脑中使用相同的 Eclipse Mars(用于 Windows x86),没关系。 所以我只能认为可能是环境的问题。
最后,我尝试了 jdk 1.6 + eclipse luna for mac(32),成功了!!,所以你可以尝试其他 eclipse 版本。
我在使用Spring Boot 2.5.1时遇到了同样的问题
从本质上讲,从 Spring Boot 2.4 开始,JUnit 5 的老式引擎已从spring-boot-starter-test
删除。 如果我们仍然想使用 JUnit 4 编写测试,我们需要添加以下 Maven 依赖项:
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
</exclusion>
</exclusions>
</dependency>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.