如果它有不同的值,如何检查键
How to check key if it has different values
我在检查特定密钥时遇到问题。
例如我有下一个响应
{
"content": [
{
"first_name": "Agent007",
"last_name": "007",
"id": "aa70d1c0-3de4",
"status": "INACTIVE"
},
{
"first_name": "ALEX",
"last_name": "Doe",
"id": "d9d5c211-5388",
"status": "ACTIVE"
}
]
}
如何检查每个“状态”是否可以具有“ACTIVE”或“INACTIVE”值?
我试过了,但是没用
And assert response.content[*].status == 'ACTIVE' || response.content[*].status == 'INACTIVE'
这(只是)一种方法:
* match each response.content[*].status == "#? _ == 'INACTIVE' || _ == 'ACTIVE'"
另请参阅文档:https://github.com/karatelabs/karate#match-each
并查看此答案以获得高级想法:
我在检查特定密钥时遇到问题。 例如我有下一个响应
{
"content": [
{
"first_name": "Agent007",
"last_name": "007",
"id": "aa70d1c0-3de4",
"status": "INACTIVE"
},
{
"first_name": "ALEX",
"last_name": "Doe",
"id": "d9d5c211-5388",
"status": "ACTIVE"
}
]
}
如何检查每个“状态”是否可以具有“ACTIVE”或“INACTIVE”值?
我试过了,但是没用
And assert response.content[*].status == 'ACTIVE' || response.content[*].status == 'INACTIVE'
这(只是)一种方法:
* match each response.content[*].status == "#? _ == 'INACTIVE' || _ == 'ACTIVE'"
另请参阅文档:https://github.com/karatelabs/karate#match-each
并查看此答案以获得高级想法: