我对 SpringRunner 类感到困惑。\n来自 Stackoverflow 和 google 确实理解了这一点SpringRunner并且SpringJunit4ClassRunner它们是一回事。
@RunWith(SpringRunner.class)\nRun Code Online (Sandbox Code Playgroud)\n\n我对这门课的理解是:
\n\n@RunWith有了 Junit5 和 spring boot,这个类不再需要了吗?
\n\n如果是的话,我们应该在 Spring Boot 和 Junit5 环境中使用什么?
\n我的项目是使用 JUnit 5 设置的,我想使用不同的 Runner 进行测试,但我什至无法使用 @RunWith 注释,因为它无法编译。在本指南中,https://www.baeldung.com/junit-5-runwith,它说 RunWith 仍然应该在 JUnit 5 中工作,所以我很困惑为什么它甚至无法编译。
甚至https://junit.org/junit5/docs/current/user-guide/#writing-tests-dependency-injection也有一个使用 RunWith 的示例,如果你向下滚动一点:
Using @RunWith(JUnitPlatform.class) will output all reported entries to stdout.
那为什么我的代码不能编译?我是不是误会了什么?
运行 gradlew 构建:
TestGameController.java:12: error: cannot find symbol
@RunWith(CacioTestRunner.class)
^
symbol: class RunWith
Run Code Online (Sandbox Code Playgroud)