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
In addition to Spring Boot options @Phil Webb pointed out, you can use plain Spting Framework features and do something like this:
@Autowired
private WebApplicationContext context;
@Autowired
private FilterChainProxy springSecurityFilter;
@Before
public void setup() {
mockMvc = MockMvcBuilders
.webAppContextSetup(context)
.addFilters(springSecurityFilter)
.apply(SecurityMockMvcConfigurers.springSecurity())
.build();
}