我的问题是 JUnit 4 测试结果未在 Eclipse 中显示。 我已将 System.out.println("....") 添加到我的测试类中的每个 @Test 方法,并且它们运行导致控制台显示输出,但是,我的包资源管理器旁边的 JUnit 选项卡未显示任何结果。它显示运行 0/0、错误 0、失败 0。
我应该补充一点,我已经添加了 JUnit 4 来构建路径。 我浏览互联网寻找答案大约一个小时,但什么也没找到。这里有什么问题?我真的很感激任何线索!
最佳答案
我在使用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>
关于java - JUnit 4 测试结果未显示在 Eclipse 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29738490/