简体   繁体   中英

Why adding @RunWith annotation to my JUnit tests if they work as expected without it?

I always add the @SpringBootTest to my test classes when using Spring Boot and my tests work as expected. I wonder what benefit do I get from also adding @RunWith(SpringRunner.class) , since all over the internet that annotation is being used.

@RunWith(SpringRunner.class)支持加载 ApplicationContext 并将 bean @Autowired放入您的测试实例中。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM