@SpringBootTest vs @ContextConfiguration vs @Import in Spring Boot Unit Test

前端 未结 2 1931
名媛妹妹
名媛妹妹 2021-02-05 14:43

I\'m working on a Spring Boot project. I\'m writing a "Unit Test" code based on "TDD," which is a little bit difficult.

@SpringBootTest l

2条回答
  •  眼角桃花
    2021-02-05 15:00

    like @MarkBramnik says if you're intent is to write a unit test you have to mock other components that uses the specific one you're testing. @SpringBootTest is recomended if you want to write an integration test that simulated the application process. @ContextConfiguration is used when you @Autowired a component in you're unit test and you have to set to the configuration that class, or the class where you created the bean

提交回复
热议问题