是否可以仅使用一个模式来匹配嵌套数组响应(使用包含)的每个元素?
我有一组带有请求参数和响应模式的 yml 文件,如下所示:
response:
appId: '#string'
attributes: '#array'
login: '#string'
permissions: '#array'
metadata:
roles: '##array'
userData:
description: '#string'
employeeId: '#string'
employeeNumber: '##string'
id: '#string'
login: '#string'
mail: '#string'
name: '#string'
然后,在可重用功能中:
* def req = read(<testDataFile>)
* match response contains req.response
我可以仅使用一种架构来匹配嵌套对象,但我不确定是否可以使用该架构来匹配嵌套数组
也许像:
response:
appId: '##string'
attributes: '##array'
attributes[*]:
key: '#string'
或任何其他表达
多谢
您不能使用单个“模式”来执行此操作,并且必须单独声明重复元素作为空手道变量:https://github.com/intuit/karate#schema-validation https://github.com/intuit/karate#schema-validation
* def foo = { a: '#number' }
* def bar = { baz: [{ a: 1 }, { a: 2 }, { a: 3 }] }
* match each bar.baz == foo
* match bar == { baz: '#[] foo' }
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)