如何在 soap UI 中使用 groovy 动态获取数组参数值

How can I get array parameter value dynamically using groovy in soap UI

我有 API 和很多参数。我正在使用 context 将特定参数的值获取到 groovy 脚本中。

但是contextreturns我null对于数组参数或者基于id的参数

成功

获取值失败

在 API 中,我通过位置和部门 ID 来获取数据。

例如:location[id] = 556d6dDRE666deda5c

那么如何使用 groovy 获取参数的值,其中参数要么是数组,要么具有 ID。

您根据提供的数据使用以下Script Assertion

//Check the response is not empty
assert context.response, 'Response is empty or null'

//Define expected values
def expectedLocationId = 'Your value here'
def expectedSkills = ['.NET']

def json = new groovy.json.JsonSlurper().parseText(context.response)

log.info "Skills : ${json.data.skills}"

log.info "Location id : ${json.location.id}"

//Assertions:

assert expectedLocationId == json.location.id, 'Location id not matching'
assert expectedSkills == json.data.skills, 'Skills not matching'