在Karate中是否有任何方法可以让我检查出如果任何值是以空字符串的形式出现,那么响应中的其他键就不应该出现----------。
例如,如果你看到下面的json响应示例,其中一个是 results[*].source.Descriptions[*].text
是空的,并且在同一个节点上,预览的对象是 results[*].source.preview
不在
所以,在空手道中,有什么直接的解决方案,可以检查Descriptions.text是否是 ''
那么在该节点上就不应该有预览。
{
"total": 10,
"count": 10,
"results": [
{
"id": "1",
"source": {
"type": "general",
"Description": [
{
"text": ""
}
]
}
},
{
"id": "2",
"source": {
"type": "general",
"preview": "Your name",
"Description": [
{
"text": "Your name is Karate"
}
]
}
}
]
}
在这里,你去。阅读文档,如果有什么不清楚的地方。
* def isValid = function(x){ var desc = x.source.Description[0].text; return desc === '' ? !x.preview : true }
* match each response.results == '#? isValid(_)'