Spring Boot 1.4 added @WebMvcTest that wire up the parts needed to do test a web slice of my application. This is fantastic, however I also want to ensure my cu
@AutoConfigureWebMvc currently import the following auto-configuration classes (see spring.factories in the spring-boot-test-autoconfigure jar):
# AutoConfigureMockMvc auto-configuration imports
org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc=\
org.springframework.boot.test.autoconfigure.web.servlet.MockMvcAutoConfiguration,\
org.springframework.boot.test.autoconfigure.web.servlet.MockMvcSecurityAutoConfiguration,\
org.springframework.boot.test.autoconfigure.web.servlet.MockMvcWebClientAutoConfiguration,\
org.springframework.boot.test.autoconfigure.web.servlet.MockMvcWebDriverAutoConfiguration
Out of this list MockMvcSecurityAutoConfiguration will automatically provide integration with the security filter.
If you need to add support for additional filters you can write your own MockMvcBuilderCustomizer (see MockMvcSecurityConfiguration.SecurityMockMvcBuilderCustomizer for inspiration).
You can either use nested @TestConfiguration class to hook your customizer into a specific test, you you could add your own spring.factories and use the AutoConfigureMockMvc key to automatically add it to all tests.