【发布时间】:2019-06-04 23:54:33
【问题描述】:
使用 intuit/karate 的 API 测试之一,
预期的 JSON 是:{name: hello,
config:[{username: abc, password: xyz},{username: qwe, password: tyu}]}
API 响应有两种可能性。
第一个可能的实际 JSON:{name: hello,
config:[{username: qwe, password: tyu},{username: abc, password: xyz}]}
第二种可能的实际 JSON:{name: hello,
config:[{username: abc, password: xyz},{username: qwe, password: tyu}]}
同样,数组元素的顺序在实际响应中是不同的,因此遵循响应验证的方法会随机抛出错误。
- 而响应 ==
- 并且响应包含
有时会抛出错误: 错误:{ 实际:response.config[0].abc,预期:response.config[0].qwe }
有时会抛出错误: 错误:{ 实际:response.config[0].qwe,预期:response.config[0].abc }
您能否提供准确的 JSON 验证空手道方法,其中整个 JSON 以及忽略包含数组的 JSON 中的元素序列?
【问题讨论】: