karate - 空手道 DSL - 使用重试直到检查数组,直到所有项目中都存在特定的键值对
问题描述
所以我有一个与下面的示例结构类似的响应。Key2 最终将更改为一个值,这意味着我的测试可以继续,所以我想通过使用重试直到确保 Key2 的所有值最终都是“测试”。我试图按照文档来做一些事情,但运气不佳。
{
"Array": [
{
"Key1": "Value1",
"Key2": "Test"
},
{
"Key1": "Value1",
"Key2": "Test"
}
]
}
任何帮助都会很棒。谢谢你。
解决方案:
And retry until karate.match("each response.Array contains { Key2: 'Test' }").pass
解决方案
试试这个,了解它是如何工作的,然后你就会知道该怎么做:
* def response =
"""
{
"Array": [
{
"Key1": "Value1",
"Key2": "Test"
},
{
"Key1": "Value1",
"Key2": "Test"
}
]
}
"""
* def result = karate.match("each response..Key2 == 'Test'")
* assert result.pass
推荐阅读
- c++ - 使用 QFileDialog 程序几秒钟后崩溃
- c# - 使用 JSON.NET 生成截断的 JSON
- utf-8 - Unicode 和 ASCII 运算符之间的区别
- python - 在 TabbedPanel 中获取小部件/项目 ID
- .net - 如何从 .NET 中的 CultureInfo 获取 ISO 3166 国家代码
- mysql - SQL语句检查用户是否被允许
- here-maps-rest - Here XYZ Studio 的底图图层
- css - WP画廊问题,在移动设备上没有响应
- excel - VBA 没有循环播放任何 PowerPoint 幻灯片
- javascript - 如何使用自定义登录处理程序在服务器上自动登录以进行 Meteor 集成测试