0

我想使用 SOAPUI Groovy 属性进行数据驱动测试。我能够运行一次脚本,但是当我试图在类内部使用这个作为 OOPS 时显示一些错误。这可能是 GroovyUtils 范围问题。请为以下工作代码提供解决方案。

以下代码替换 xml 值并运行请求。

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)`

在类中执行相同的代码时不起作用。

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 - 货币转换器 (webservicex)

4

1 回答 1

2

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

test1.runReq('USD','INR', testRunner, context)
于 2015-10-19T06:13:42.780 回答