How we can pass an array to a method using Groovy Script TestStep in SoapUI Pro?

Thursday, July 10, 2014

I'm new to Groovy Script with SoapUI. I have to pass an array to a method and modify the values and then print them in the log. For that, I have written the following script. But its not working as expected.



String [] countries = new String[5];
void ReuseArray(String[] regions){};

countries[0] = "India";
countries[1] = "Singapore";
countries[2] = "Indonesia";
countries[3] = "Japan";
countries[4] = "Thailand";

for (int i=0; i<5; i++)
{
log.info("Country :" + countries[i]);
}

ReuseArray(countries);

void ReuseArrayData(String[] regions)
{
for (int i=0; i<5; i++)
{
log.info("Method :" + regions[i]);
}
}


The above script produces the following output:


Thu Jul 10 19:08:13 IST 2014:INFO:Welcome

Thu Jul 10 19:08:13 IST 2014:INFO:Country :India

Thu Jul 10 19:08:13 IST 2014:INFO:Country :Singapore

Thu Jul 10 19:08:13 IST 2014:INFO:Country :Indonesia

Thu Jul 10 19:08:13 IST 2014:INFO:Country :Japan

Thu Jul 10 19:08:13 IST 2014:INFO:Country :Thailand


Please correct me If I'm wrong..


Thanks Karunagara Pandi G







http://ift.tt/1qZ4Eh2