Feb 01, 2018 · This example shows how to unit test Spring File upload controller by using MockMultipartFile.. MockMultipartFile does not use the application registered MultipartResolver, that means it is only suitable for testing application controllers that access multipart uploads.

Aug 31, 2018 · Also this documentation recommends to use the Spring test components before others like EasyMock to test Spring classes. These mock objects are targeted at usage with Spring’s Web MVC framework and are generally more convenient to use than dynamic mock objects such as EasyMock or alternative Servlet API mock objects such as MockObjects. Jan 29, 2017 · Mock the request. Spring boot gives us the possibility to simulate the http request without any browser using the annotation @WebMvcTest. This annotation configure @MockMvc that simulates the request for the tests. Mock the service. As we see in the picture we don’t need to test the service, maybe it is retrieving some data from the database.