{
"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
com.jayway.jsonpath.JsonPath.read(prev.getResponseDataAsString(), '$..status').each { status ->
if (!(1..2).contains(status)) {
AssertionResult.setFailure(true)
AssertionResult.setFailureMessage('Comparison failed, got: ' + status)
}
}
status
值和评估它是否是1
和2
之间包含地。在意想不到的情形发生的相关采样(收费)断言的scope将被标记为失败:
退房Scripting JMeter Assertions in Groovy - A Tutorial文章上的JMeter的基于代码的断言概念的更多信息。