SoapUI JSONPath断言基于返回项的计数

tom*_*tom 2 soapui assertions jsonpath

在对我的请求的响应中,我得到了一个JSON项目列表

{
"Id": 111,
"Name": "aaa"
},
{
"Id": 222,
"Name": "bbb"
}
Run Code Online (Sandbox Code Playgroud)

我需要声明,在我的回复中,至少有5个项目.使用JSONPath Count时,我只能使用$ ..*来检查确切的值.不幸的是,我不知道返回的确切项目数,只要响应中有超过5项,一切都可以.我可以使用任何JSONPath断言吗?

tom*_*tom 6

看来我必须使用Script Assertion:

import groovy.json.JsonSlurper
def ResponseMessage = messageExchange.response.responseContent
def ParsedMessage = new JsonSlurper().parseText(ResponseMessage)
assert !(ParsedMessage.isEmpty())
assert ParsedMessage.Id != null
assert ParsedMessage.Name != null
assert ParsedMessage.size() > 30
Run Code Online (Sandbox Code Playgroud)