I am using Spring for MVC tests
Here is my test class
@RunWith(SpringRunner.class) @WebMvcTest public class ITIndexController { @Autowired W
If you use SpringJUnit4ClassRunner instead of SpringRunner you can catch your requests in security layer. If you are using basic authentication you have to user httpBasic method inside mockMvc.perform
mockMvc.perform(get("/").with(httpBasic(username,rightPassword))