如何在 SoapUI 的 Groovy 脚本中定义具有返回类型的方法?

Kar*_*ndi 2 testing scripting groovy automation soapui

我需要一个应该向调用者返回字符串类型值的方法。为此,我编写了以下脚本。

String  getMethodValue = ReturnCountryName("US");

String ReturnCountryValue(String CName)
{
    CName = "Mauritius";
    return CName;
}

// Assign values to the global properties and call the servive
com.eviware.soapui.SoapUI.globalProperties.setPropertyValue( "CountryName", getMethodValue )

// Call GetCitiesByCountry service to run
def testStep = testRunner.testCase.testSteps['GetCitiesByCountry'];
testStep.run(testRunner,context);

// Message
log.info("Testcase execution is completed successfully.")
Run Code Online (Sandbox Code Playgroud)

我无法找到错误消息的解决方案,如下面的屏幕截图所示。

在此处输入图片说明

我该怎么做才能克服脚本中的这个错误?

谢谢,
Karunagara Pandi G

Opa*_*pal 6

你声明一个方法 ReturnCountryValue

String ReturnCountryValue(String CName) {
    CName = "Mauritius";
    return CName;
}
Run Code Online (Sandbox Code Playgroud)

但是打电话ReturnCountryName。更改方法名称或调用名称。