断言响应主体为空列表,并保证

阿塔曼罗曼语:

我该如何使用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] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章