我想使用 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(StringCurrencyFrom, StringCurrencyTo, testRunner, context){....}
并将其调用为
test1.runReq('USD','INR', testRunner, context)
关于java - 如何在 Groovy 中使用 SOAPUI 类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33032069/