如何使用rest-assured (2.4.0)检查响应json是否为空列表?
给定我尝试的响应[] (带有标头content-type=application/json):
.body(Matchers.emptyArray()) // expected: an empty array, actual: []
.body("/", Matchers.emptyArray()) // invalid expression /
.body(".", Matchers.emptyArray()) // invalid expression .发布于 2015-05-26 22:09:10
问题是(可能) REST Assured返回一个列表,而不是一个数组( Hamcrest区分了两者)。您可以执行以下操作:
.body("", Matchers.hasSize(0))或
.body("$", Matchers.hasSize(0))或
.body("isEmpty()", Matchers.is(true))发布于 2020-04-02 18:47:28
受到@Johan所说的启发,我尝试了一下,我认为它告诉读者的比其他建议更多。
.body("", equalTo(Collections.emptyList()))https://stackoverflow.com/questions/30460682
复制相似问题