简体   繁体   中英

How to use class in Groovy for SOAPUI

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)

尝试以这种方式使用它,将public void runReq(String CurrencyFrom , String CurrencyTo, testRunner, context){....}命名为

test1.runReq('USD','INR', testRunner, context)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM