我想在响应数组下的每个项目中添加包含“训练”的技能数组断言。我怎样才能使用匹配每种格式来做到这一点* match each response contains { password: 'abc123' }
(不使用 JsonPath 表达式)。我预计下面的示例的测试会失败,因为第四个对象中缺少技能数组。
Scenario: Test scenario
* def response =
"""
[
{
id: 1,
name: "John",
password: "abc123",
skills :[ "training", "management"
]
},
{
id: 2,
name: "David",
password: "abc123",
skills :[ "training", "management"
]
},
{
id: 3,
name: "David",
password: "abc123",
skills :[ "training", "coding"
]
},
{
id: 4,
name: "David",
password: "abc123"
}
]
"""
干得好:
* def expectedSkills = ['training']
* match each response contains { skills: '#(^expectedSkills)' }
你知道,你真的应该阅读文档。这会节省你很多时间:)https://github.com/intuit/karate#schema-validation https://github.com/intuit/karate#schema-validation
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)