【发布时间】:2019-06-19 07:50:14
【问题描述】:
我想使用 groovy 脚本为响应断言编写代码,响应数据如下:
[
{
"fieldId":"947bb60f",
"id":"e7b8ad2b",
"name":"field",
}
]
尝试使用以下我收到错误的 groovy 脚本(失败消息)。
if (!jsonResponse.keySet().containsAll(["fieldId","id","name"] )) {
failureMessage += "The json response body has wrong structure or error msg.\n\n";
}
相同的脚本在单树结构下运行良好,如下所示。感谢您使用 groovy 脚本对此提供的帮助。
[
"fieldId":"947bb60f",
"id":"e7b8ad2b",
"name":"field",
]
【问题讨论】:
-
jsonResponse[ 0 ]........应该可以解决问题 -
你有一个地图列表。你的支票是为一张地图写的。您必须迭代列表并在该迭代中进行检查(例如,使用
for或each)
标签: groovy jmeter jmeter-4.0