cancel
Showing results for 
Search instead for 
Did you mean: 

Can we add multiple methods in groovy script ??

Former Member
0 Kudos

HI I am using groovy script to generate some report and in my groovy script I have to use multiple method. Is it possible to write groovy for that.If yes what will be the syntax for that ? Thanks in advance, Amit

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Amit,

If you want to use beanshell,you can follow below syntax.

//import statement..

String getName(List list){ String str = "JHON"; return str; }

System.out.println(getName(new ArrayList()));

Regards,

Former Member
0 Kudos

I have tried the same syntax in groovy script and it's working.

Answers (1)

Answers (1)

Former Member
0 Kudos

You can create groovy methods in the script:

 // groovy script
 
 //call myMethod
 myMethod()
 
 def myMethod() {
 // method does something
 }