我有这样的回复:
{
"timestamp": "2016-05-03T12:55:54Z",
"data": {
"update_by": null,
"create_at": "2016-05-03T12:55:54Z",
"delete_by": null,
"update_at": "2016-05-03T12:55:54Z",
"create_by": null,
"primary": true,
"address": "email@gmail.com",
"delete_at": null,
"type": "public",
"id": "c770b810-5895-88fa-aa90-88bba76678dd"
},
"success": true
}
我使用这个groovy代码来保存一些数据。 import groovy.json.JsonSlurper
def response = context.expand( '${create_email#Response#declare namespace ns1=\'https://zenith.io/ns/20780518\'; //ns1:create_person_email_resp[1]/ns1:item[1]/ns1:response[1]}' )
def slurper = new JsonSlurper()
def result = slurper.parseText(response)
log.info result.data.id
log.info result.data.address
log.info result.data.type
log.info result.data.primary
testRunner.testCase.setPropertyValue("email_id", result.data.id )
testRunner.testCase.setPropertyValue("email", result.data.address )
testRunner.testCase.setPropertyValue("type", result.data.type )
testRunner.testCase.setPropertyValue("primary", result.data.primary )
无法保存布尔值(主要)的数据。 我看到这个错误:
groovy.lang.MissingMethodException:没有方法签名:com.eviware.soapui.impl.wsdl.WsdlTestCasePro.setPropertyValue()适用于参数类型:(java.lang.String,java.lang.Boolean)值: [primary,false]可能的解决方案:setPropertyValue(java.lang.String,java.lang.String),getPropertyValue(java.lang.String)错误在第17行
如何在属性中保存布尔值?
答案 0 :(得分:2)
testRunner.testCase.setPropertyValue("primary", result.data.primary as String)