如果一个json中包含另一个带有空手道的json,则匹配

时间:2019-02-14 12:45:05

标签: karate

我必须验证一个json是否最后包含另一个json,例如此测试:

def subset = { bar: { foo: 'xxx' }} 
def superset = { bar: { foo: 'xxx', baz: 'yyy' }} 
match superset contains subset

如果失败,是正确的吗?

path: $.bar, actual: {foo=xxx, baz=yyy}, expected: {foo=xxx}, reason: actual value has 1 more key(s) than expected: {baz=yyy}

谢谢

1 个答案:

答案 0 :(得分:0)

您在这里:

* def part = { foo: 'xxx' } 
* def superset = { bar: { foo: 'xxx', baz: 'yyy' } } 
* match superset == { bar: '#(^part)' }

请阅读文档:https://github.com/intuit/karate#contains-short-cuts