【问题标题】:SoapUI/Groovy: can not get response when set test step name variableSoapUI/Groovy:设置测试步骤名称变量时无法获得响应
【发布时间】:2016-04-27 14:44:31
【问题描述】:

我的 groovy 代码如下。当我在以下位置使用真实的测试步骤名称时,我可以获得请求和响应:

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)

【问题讨论】:

  • S.Spieker,非常感谢您的帮助!这是我在网站上的第一个问题。原来的代码格式不太好。

标签: groovy soapui


【解决方案1】:

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

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)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多