在使用 Spring Boot 时,我总是将 @SpringBootTest
添加到我的测试类中,并且我的测试按预期工作。我想知道添加 @RunWith(SpringRunner.class)
能带来什么好处,因为整个互联网都在使用该注释。
最佳答案
@RunWith(SpringRunner.class)
支持加载 ApplicationContext 并将 beans @Autowired
添加到测试实例中。
关于java - 如果 JUnit 测试在没有 @RunWith 注释的情况下也能按预期工作,为什么还要向我的 JUnit 测试添加 @RunWith 注释呢?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59586460/