繁体   English   中英

如何在Groovy中为SOAPUI使用类

[英]How to use class in Groovy for SOAPUI

我想将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)

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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