Using this annotation will disable full auto-configuration and instead apply only
configuration relevant to MVC tests (i.e. @Controller,
@ControllerAdvice, @JsonComponent,
Converter/GenericConverter, Filter, WebMvcConfigurer
and HandlerMethodArgumentResolver beans but not @Component,
@Service or @Repository beans).
By default, tests annotated with @WebMvcTest will also auto-configure Spring
Security and MockMvc (include support for HtmlUnit WebClient and Selenium
WebDriver). For more fine-grained control of MockMVC the
@AutoConfigureMockMvc annotation can be used.
Typically @WebMvcTest is used in combination with
@MockBean or
@Import to create any collaborators required by your @Controller
beans.
If you are looking to load your full application configuration and use MockMVC, you
should consider @SpringBootTest combined with
@AutoConfigureMockMvc rather than this annotation.
When using JUnit 4, this annotation should be used in combination with
@RunWith(SpringRunner.class).