如何检查 json 响应数组包含子字符串
how to check the json response array contains the substring
如何断言 json 响应数组包含字符串值中的子字符串。
我试过了,但是断言失败了 response.then().body("response.content.Date", Matchers.everyItem(contains("2019-03") ));
我的回复正文是
{
"response": {
"totalSize": 2,
"content": [
{
"requestId": " 931-f8222e",
"name": "gowtham",
"date": "2019-03-06",
"issue": "i have a cause"
},
{
"requestId": " 931-f8222e",
"name": "tharun",
"date": "2019-03-09",
"issue": "has a issue in billing"
}
]
}
}
我想获取月份(值)中的所有记录并断言显示给定月份数据的响应
我找到了解决方案。你们非常亲密。您可以使用 containsString
来匹配子字符串,而不是使用匹配完整字符串的 contains
。
代码:
response.then().body("response.content.date", Every.everyItem(Matchers.containsString("2019-03")));
如何断言 json 响应数组包含字符串值中的子字符串。
我试过了,但是断言失败了 response.then().body("response.content.Date", Matchers.everyItem(contains("2019-03") ));
我的回复正文是
{
"response": {
"totalSize": 2,
"content": [
{
"requestId": " 931-f8222e",
"name": "gowtham",
"date": "2019-03-06",
"issue": "i have a cause"
},
{
"requestId": " 931-f8222e",
"name": "tharun",
"date": "2019-03-09",
"issue": "has a issue in billing"
}
]
}
}
我想获取月份(值)中的所有记录并断言显示给定月份数据的响应
我找到了解决方案。你们非常亲密。您可以使用 containsString
来匹配子字符串,而不是使用匹配完整字符串的 contains
。
代码:
response.then().body("response.content.date", Every.everyItem(Matchers.containsString("2019-03")));