【问题标题】:Validating an attribute inside JsonArray using restassured使用 reassured 验证 JsonArray 中的属性
【发布时间】:2016-05-19 13:51:45
【问题描述】:

我有一个像下面这样的 json

{
"hasErrorResponse": "false",
"responseObject": [{
    "success": true,
    "errorMessage": null,
    "availablity": "YES",
    "errorCode": null,
    "availableQtys": 1234,
    "prId": "451667"
}]

}

如果我愿意,现在使用RestAssured

response.then().assertThat().body("responseObject.prId", equalTo("451667"));

它失败了,因为它说Expected: 451667 but Got: [451667]

我猜这是因为它将prId 属性作为ArrayList 而不是String。我该如何验证这个场景?

【问题讨论】:

    标签: json rest-assured


    【解决方案1】:

    hasItems matcher 用于验证集合中的任何内容

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-12-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多