Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to define a method with return type in Groovy script in SoapUI?

I need a method that should return a string type value to the caller. For that, I have written the following script.

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

I'm not able to find the solution for the error message as shown in the following screenshot.

enter image description here

What shall I do to overcome this error in the script?

Thanks,
Karunagara Pandi G

like image 271
Karunagara Pandi Avatar asked Aug 31 '25 10:08

Karunagara Pandi


1 Answers

You declare a method ReturnCountryValue

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

but call ReturnCountryName. Change the name of the method or the name of the invocation.

like image 157
Opal Avatar answered Sep 03 '25 12:09

Opal