Forum Discussion

easyfish's avatar
easyfish
Contributor
9 years ago

can not get test step response in groovy

Hello,

My groovy code is as below.

I can get request, while fail to get response.

The error is

org.apacge.xmlbeans.XmlException: error: unexpected end of file after null
error at line: xx

 

The test step that currentStep points to has been executed and has request/reponse.

if I change  variable

def response=context.expand('${${currentStep.name}#response}')

 

to  the real test step name

def response=context.expand('${Additional#response}') // additional is the test step name

 

The groovy script runs well.

 

My questions

1. Why can I not get the response?

2.  If the test step name has space, like "Additional code", how to make it work in the context.expand. I have tried " "   and '  ', they don't work.

--------------------

 

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
def xmlreq=new XmlHolder(request)

 

// get the hold of response
def response=context.expand('${${currentStep.name}#response}')
log.info " response: " + response
def xmlres=new XmlHolder(response)      // error occurs here

 

Thanks for your kind help in advance.