I was trying to write unit test for Servlet using sprint-test using mock object
my maven dependency is:
According to the Spring Framework Reference for Testing you should be using annotations to autowire your mocks. The example in the spring reference:
`
@WebAppConfiguration
@ContextConfiguration
public class WacTests {
@Autowired WebApplicationContext wac; // cached
@Autowired MockServletContext servletContext; // cached
@Autowired MockHttpSession session;
@Autowired MockHttpServletRequest request;
@Autowired MockHttpServletResponse response;
@Autowired ServletWebRequest webRequest;
//...
}
`
A different example (without annotations) can be found here