Spring MVC
@Test public void testController () throws Exception { ResultMatcher ok = MockMvcResultMatchers.status().isOk(); MockMultipartFile file = new MockMultipartFile("user-file", "test.txt", null, "test data".getBytes()); MockHttpServletRequestBuilder builder = MockMvcRequestBuilders.fileUpload("/upload") .file(file); this.mockMvc.perform(builder).andExpect(ok); }