I would like to use SOAPUI Groovy property for data driven testing. I am able to run the script for Once but while I am trying to use this inside class as OOPS Showing some error. It might be a GroovyUtils scope issue. Please provide solution for the following working code.
The following code replaces xml values and runs the request.
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
def Req = groovyUtils.getXmlHolder("ConversionRate#Request")
def CurrenctFrom = 'USD'
de CurrencyTo = 'INR'
Req["//*:ConversionRate/*:FromCurrency"] = CurrenctFrom
Req.updateProperty()
Req["//*:ConversionRate/*:ToCurrency"] = CurrencyTo
Req.updateProperty()
def testStep = testRunner.testCase.testSteps['ConversionRate']
testStep.run(testRunner,context)`
Same code is not working when executed within a class.
test.log = log
def test1 = new test()
test1.runReq('USD','INR')
class test {
def static log
public void runReq(String CurrencyFrom , String CurrencyTo) {
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
def Req = groovyUtils.getXmlHolder("ConversionRate#Request")
Req["//*:ConversionRate/*:FromCurrency"] = CurrenctFrom
Req.updateProperty()
Req["//*:ConversionRate/*:ToCurrency"] = CurrencyTo
Req.updateProperty()
def testStep = testRunner.testCase.testSteps['ConversionRate']
testStep.run(testRunner,context)
}
}
WSDL - currency Converter (webservicex)
Try to use it this way,
public void runReq(String CurrencyFrom , String CurrencyTo, testRunner, context){....}
and call it as
test1.runReq('USD','INR', testRunner, context)