junit测试 jsonPath如何获取json数据里面对象的个数大小长度
做spring项目时候数据返回格式json 如何测试json里面的集合个数是否正确
使用jsonPath
jsonPath("$.msgContentList",hasSize(1))
上面就是获取msgContentList集合的大小是否是1个
@Test
public void testInsertMsgContent() throws Exception {
mockMvc.perform(get("/msg/findmsgs", "json").accept(MediaType.APPLICATION_JSON)
.param("title", "test222")
).andExpect(MockMvcResultMatchers.jsonPath("$.msgContentList",hasSize(1)));
}
来源://作者:/更新时间:2014-02-21
顶
踩
相关文章:
