SoapUI / Groovy:设置测试步骤名称变量时无法获得响应

时间:2016-04-25 06:44:06

标签: groovy soapui

我的常规代码如下。当我在:

中使用真实的测试步骤名称时,我可以得到请求和响应
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)

1 个答案:

答案 0 :(得分:0)

我在阅读完信息后解决了我的问题。

http://community.smartbear.com/t5/SoapUI-NG/Resolved-Pass-a-variable-into-context-expand-code/td-p/43025

    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)
相关问题