{
"id": 280,
"name": "Kru",
"description": "alphabetic description",
"status": 2,
"condition_type": "1",
"created_at": "2019-02-05T14:43:04.000Z",
"updated_at": "2019-02-05T14:43:04.000Z"
},
{
"id": 25,
"name": "Krut",
"description": "abckdk eje jw s",
"status": 1,
"condition_type": "0",
"created_at": "2019-02-05T11:11:02.000Z",
"updated_at": "2019-02-05T11:11:02.000Z"
}我试图断言上面的JSON响应。如果响应的状态值为1和2,则我的测试用例通过,否则失败。现在,我一次只能断言一个值。我如何断言两个值?提前谢谢你。JSON assertion I implemented
发布于 2019-02-11 14:31:38
com.jayway.jsonpath.JsonPath.read(prev.getResponseDataAsString(),'$..status').each { status -> if (!(1..2).contains( status) ) { AssertionResult.setFailure(true) AssertionResult.setFailureMessage(‘比较失败,获取:’+status)}}
status值,并评估它是否包含在1和2之间。如果出现意外状态,断言scope中的相关采样器将被标记为failed:
有关JMeter中基于代码的断言概念的更多信息,请查看Scripting JMeter Assertions in Groovy - A Tutorial文章。
发布于 2021-03-03 07:39:23

我需要的正是你最近解释的东西,所以我一直在玩它,这个^对我很有效:) (当然,顺序很重要)
https://stackoverflow.com/questions/54587468
复制相似问题