空手道 - 如何检查数组是否包含值?
Karate - how to check if array contains values?
给定
我已经定义了数组
* def array = [
{"code": "codeA", "boolValue": false, "a": 5, "c": false},
{"code": "codeA", "boolValue": true, "a": 7, "c": true},
{"code": "codeB", "boolValue": true, "a": 1, "c": false}
]
和变量
* def expected = { "code": "codeB", "boolValue": true }
问题
在 array
的最后一个元素中有 expected
值。
但它包含一些额外的值,这就是为什么我尝试检查它时它一直失败的原因。
如何检查数组是否包含期望值?
这将在 0.9.6.RC4 中工作:
* match array contains deep expected
在以前的版本中:
* match array contains '#(^expected)'
请阅读文档:https://github.com/intuit/karate/tree/develop#schema-validation
给定
我已经定义了数组
* def array = [
{"code": "codeA", "boolValue": false, "a": 5, "c": false},
{"code": "codeA", "boolValue": true, "a": 7, "c": true},
{"code": "codeB", "boolValue": true, "a": 1, "c": false}
]
和变量
* def expected = { "code": "codeB", "boolValue": true }
问题
在 array
的最后一个元素中有 expected
值。
但它包含一些额外的值,这就是为什么我尝试检查它时它一直失败的原因。
如何检查数组是否包含期望值?
这将在 0.9.6.RC4 中工作:
* match array contains deep expected
在以前的版本中:
* match array contains '#(^expected)'
请阅读文档:https://github.com/intuit/karate/tree/develop#schema-validation