1)代替
.andExpect(jsonPath("$.data.roles.length").value(correctRoles.size()));尝试
.andExpect(jsonPath("$.data.roles.length()").value(correctRoles.size()));要么
.andExpect((jsonPath("$.data.roles", Matchers.hasSize(size))));2)代替
for (AuthorityRole role : correctRoles) // doesn't work actions.andExpect(jsonPath("$.data.roles[?(@=='%s')]", role.toString()).exists());尝试
actions.andExpect((jsonPath("$.data.roles", Matchers.containsInAnyOrder("role1", "role2", "role3"))));请记住,您必须添加hamcrest库。



