Spring Framework 3.2 introduces a very elegant way to test Spring MVC controller using MockMvc. Based on the documentation, there are two ways to configure MockMvc:- MockMvcBuilders.webAppContextSetup(webApplicationContext).build() MockMvcBuilders.standaloneSetup(controller).build() The first approach will automatically load the Spring configuration and inject WebApplicationContext into the test.