我正在尝试/上传测试。这是我的方法:
@PostMapping("/upload")
public FileClass upload(MultipartFile file,
Long id,
@RequestParam(required = false, defaultValue = "false") Boolean isFile
) {
return getService().upload(file, id, isFile);
}
和下面的我的测试班:
@Test
public void upload() throws Exception {
MockMultipartFile mockMultipartFile =
new MockMultipartFile("test", "test.txt", "multipart/form-data", "test".getBytes());
getMockMvc().perform(multipart("/upload")
.file(mockMultipartFile)
.param("isFile","false")
.header("authorization", getToken()))
.andExpect(status().isOk());
}
此测试返回404错误: java.lang.AssertionError:预期状态:<200>,但为:<404> 我怎么了