据我所知
MockHttpServletResponse
所以你能做的就是利用杰克森
ObjectMapper
将json字符串转换为特定类型
像这样的东西
String json = rt.getResponse().getContentAsString();
SomeClass someClass = new ObjectMapper().readValue(json, SomeClass.class);
这将给你更多的控制权,让你断言不同的东西。
MockMvc::perform
回报
ResultActions
andExpect
这需要
ResultMatcher
例如
mvc.perform( .....
......
.andExpect(status().isOk())
.andExpect(jsonPath("$.firstname").value("john"))
.andExpect(jsonPath("$.lastname").value("doe"))
.andReturn();