如何找到前三个值的总和并将其与另一个值进行比较 属性
How to find sum of first three values and compare it with another property
这是我的 json 响应,我需要对前 3 个值求和并将其与 SOAPUI 中的总值进行比较。
{
"major": 21,
"minor": 1,
"critical": 3,
"total": 25
}
您可以将 Script Assertion
用于 REST 请求测试步骤,如下所示:
脚本:
assert context.response, 'Response is empty or null'
//Parse the json
def json = new groovy.json.JsonSlurper().parseText(context.response)
//Check if sum of 3 properties equal to toal
assert json.total == json.with { major + minor + critical}
这是相同的独立版本,您可以在线试用 demo
这是我的 json 响应,我需要对前 3 个值求和并将其与 SOAPUI 中的总值进行比较。
{
"major": 21,
"minor": 1,
"critical": 3,
"total": 25
}
您可以将 Script Assertion
用于 REST 请求测试步骤,如下所示:
脚本:
assert context.response, 'Response is empty or null'
//Parse the json
def json = new groovy.json.JsonSlurper().parseText(context.response)
//Check if sum of 3 properties equal to toal
assert json.total == json.with { major + minor + critical}
这是相同的独立版本,您可以在线试用 demo