【发布时间】:2020-02-05 05:39:40
【问题描述】:
我有以下内容,我正在比较两个环境的响应。 在我的情况下,对于某些服务,响应 json 元素/数组顺序不是强制性的,但对于某些服务是强制性的。所以我使用了包含,但我怀疑任何响应中是否缺少任何元素/数组 在比较以下两个时说:
A: {
"hotels": [
{ "roomInformation": [{ "roomPrice": 618.4 }], "totalPrice": 618.4 },
{ "roomInformation": [{ "roomPrice": 679.79}], "totalPrice": 679.79 }
]
}
B:
{
"hotels": [
{ "roomInformation": [{ "roomPrice": 618.4 }], "totalPrice": 618.4 },
{ "roomInformation": [{ "roomPrice": 680.79}], "totalPrice": 680.79 },
{ "roomInformation": [{ "roomPrice": 679.79}], "totalPrice": 679.79 }
]
}
使用下面的匹配每个 contains 给出肯定的结果?请建议
Feature:
Background:
Scenario: test
* json input = read('input.json')
* def stage= call read('A.feature') input;
* def prod = call read('B.feature') input;
#* def rp = $prod[*].response
#* def rs = $stage[*].response
#* match rs contains rp
#* match each $prod[*].response[*] contains $stage[*].response
# * match each $prod[*].response[*] contains $stage[*].response.[*]
【问题讨论】:
标签: karate