@SpringBootTest
is the general test annotation. If you're looking for something that does the same thing prior to 1.4, that's the one you should use. It does not use slicing at all which means it'll start your full application context and not customize component scanning at all.
@WebMvcTest
is only going to scan the controller you've defined and the MVC infrastructure. That's it. So if your controller has some dependency to other beans from your service layer, the test won't start until you either load that config yourself or provide a mock for it. This is much faster as we only load a tiny portion of your app. This annotation uses slicing.
<출처: https://stackoverflow.com/questions/39865596/difference-between-using-mockmvc-with-springboottest-and-using-webmvctest>
빌드 시간이 많이 걸리는 Spring Boot Application의 일부를 빨리 unit test -> 수정 -> unit test를 하고 싶은데 @SpringBootTest는 "slicing"을 하지 않아서 전체를 디버깅 모드로 실행시키는 거나 마찬가지..
@WebMvcTest는 "controller"만 로딩해주고, 그 외의 bean들은 mock을 해줘야 한다는 거네요.
그러면 해당 controller나 dependency가 있는 다른 bean들 모두를 mock을 해줘야 하는건지..
'Coding' 카테고리의 다른 글
default export와 named export의 차이 (0) | 2017.07.05 |
---|---|
Node 8 그리고 npm 5 (0) | 2017.06.16 |
Angular? AngularJS? (0) | 2017.06.15 |
h2 embedded mode에서 한글이 깨지는 경우 (0) | 2015.06.15 |
How to change ${USER} in IntelliJ IDEA (1) | 2015.06.02 |