我该如何使用rest-assured(2.4.0)检查响应json是否为空列表?
给定响应[]
(带有header content-type=application/json
),我尝试:
.body(Matchers.emptyArray()) // expected: an empty array, actual: []
.body("/", Matchers.emptyArray()) // invalid expression /
.body(".", Matchers.emptyArray()) // invalid expression .
问题是(可能)REST保证人返回列表而不是数组(并且Hamcrest区分两者)。你可以做:
.body("", Matchers.hasSize(0))
要么
.body("$", Matchers.hasSize(0))
要么
.body("isEmpty()", Matchers.is(true))
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句