简体   繁体   English

如何在Groovy中为SOAPUI使用类

[英]How to use class in Groovy for SOAPUI

I would like to use SOAPUI Groovy property for data driven testing. 我想将SOAPUI Groovy属性用于数据驱动的测试。 I am able to run the script for Once but while I am trying to use this inside class as OOPS Showing some error. 我可以只运行一次脚本,但是当我尝试使用此内部类作为OOPS时显示一些错误。 It might be a GroovyUtils scope issue. 这可能是GroovyUtils范围的问题。 Please provide solution for the following working code. 请提供以下工作代码的解决方案。

The following code replaces xml values and runs the request. 以下代码替换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)`

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