我的常规代码如下。当我在:
中使用真实的测试步骤名称时,我可以得到请求和响应def request=context.expand('${"testStepName"#request}')
def response=context.expand('${"testStepName"#response}')
当我改为使用变量时:
def request=context.expand('${${currentStep.name}#request}')
def response=context.expand('${${currentStep.name}#response}')**
我只能得到请求,但却没有得到回应。错误是
org.apacge.xmlbeans.XmlException: error: unexpected end of file after null
error at line: xx
currentStep指向的测试步骤已执行并有请求/响应。
import com.eviware.soapui.support.XmlHolder
import com.eviware.soapui.impl.wsdl.testcase.WsdlTestRunContext
import groovy.sql.Sql
import oracle.jdbc.driver.OracleTypes
import com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStep
def currentStep = testRunner.testCase.getTestStepAt(6)
log.info "currentStep.name: " + currentStep.name
// get the hold of request
def request=context.expand('${${currentStep.name}#request}')
log.info " request: " + request
// get the desired node value from request
def xmlreq=new XmlHolder(request)
// get the hold of response
def response=context.expand('${${currentStep.name}#response}')
log.info " response: " + response
// get the desired node value from response
def xmlres=new XmlHolder(response)
答案 0 :(得分:0)
我在阅读完信息后解决了我的问题。
String propertySpec = '${' + currentStep.name + '#Response}'
log.info "propertySpec : ${propertySpec}"
def response = context.expand(propertySpec)
log.info("context.expand(propertySpec) : ${response}")
def xmlres=new XmlHolder(response)