我想测试的 Spring 方法
@RequestMapping(value="/files", method=RequestMethod.GET)
@ResponseBody
public List<FileListRequest> get() {
return getMainController().getAllFiles();
}
我想确保所有对 /files 的调用都会以 List[FileListRequest] 响应。如何?
这是测试应该采用的方法。
@Test
public void testGetAll() throws Exception {
this.mockMvc.perform(get("/files").accept("application/json"))
.andExpect(status().isOk())
.andExpect(content().contentType(SOMETHING);
}
我可以简单地替换一些东西还是我完全错了?
我可以对 perform() 返回的对象运行断言方法吗?