【发布时间】:2018-04-16 06:53:00
【问题描述】:
我想断言来自休息控制器的 json 输出,但我得到“预期:null 但:是 ”。这是我的测试代码:
mockMvc.perform(post(TEST_ENDPOINT)
.param("someParam", SOMEPARAM)
.andDo(print())
.andExpect(status().is2xxSuccessful())
.andExpect(jsonPath("*.errorMessage").value(IsNull.nullValue()));
json:
{
"some_string": {
"errorMessage": null
}
}
我发现了类似的问题How to assertThat something is null with Hamcrest?,但两个答案都不起作用。也许这是由于 jsonPath,导致它在 [] 括号中返回空值?是断言框架的bug吗?
【问题讨论】: