Spting Boot Testing
September 11, 2021
M04 Q42 When do you want to use @WebMvcTest? What does it auto-configure?
You should use @WebMvcTest
annotation when you want to write Integration Test that is focused on web layer of your application. @WebMvcTest
approach will create ApplicationContext
that contains only web components and omits any other components that are not part of web layer. Other components, if required for the test, can be mocked with usage of @MockBean
annotation or delivered by @Configuration
annotated class imported with usage of @Import
annotation.