我想使用 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)