@Before public void runBeforeTestMethod() { System.out.println("Before test method"); String contextLoc = "classpath:appContext.xml"; String warDir = "src/main/webapp"; mockMvc = MockMvcBuilders.xmlConfigSetup("classpath:/WEB-INF/spring/appServlet/servlet-context.xml") .configureWebAppRootDir(warDir, false) .build(); }