0

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)

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Error Hunter
  • 1,354
  • 3
  • 13
  • 35

1 Answers1

2

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)
Eiston Dsouza
  • 394
  • 2
  • 13