cancel
Showing results for 
Search instead for 
Did you mean: 

Global groovy class or a groovy wrapper class

Highlighted
Super Contributor

Global groovy class or a groovy wrapper class

Let me state what I am curently doing because I have not found a good way of just chaving my code as a class and just re-using it.

Currently I have same grovy code everywhere

How can I just create a class and just import and use it

Issues I have it that the class needs to use Ready API test runners and context in order to run the tests

so that would mean I will have  to import these modules

I have not found a good way of doing ths yet

But in hindsight I would really like to avoid having the same code all over the place.

 

4 REPLIES
Contributor

Re: Global groovy class or a groovy wrapper class

not sure if you would like to encapsulated your groovy script into a class or method.

why not you put your groovy code into a .groovy file? ReadyAPI points  to script library(./script) by default, you're able to put your code there. also you can specify a folder to save scripts and then change your script library path setting.

Surely, defined a class for reference or defined a method to call.

(example)

Login.groovy (you may new a object like: def login = new Login())

/myTest/Login.groovy (you may new a object like: def login = myTest.Login())

Community Leader

Re: Global groovy class or a groovy wrapper class

Hello @sanj

 

I was doing the same thing earlier there was no code reusability in my Project but i found below article and this is very usefull for code reusability.

Please go through this document and follow simple Steps:

 

Code Reusability

 

Do Like and accept if you find it as solution.

 

Thanks,

Himanshu

Click "Accept as Solution" if my answer has helped, and remember to give "kudos" Smiley Happy

Thanks and Regards,
Himanshu Tayal
Moderator

Re: Global groovy class or a groovy wrapper class

Hi,

Great suggestions, guys! Thank you.

 

@sanj, have you had a chance to try the suggestions?

If your question is answered, don't forget to mark this topic as Solved Smiley Wink

Thanks in advance,

 

Olga Terentieva,
SmartBear Assistant Community Manager
Super Contributor

Re: Global groovy class or a groovy wrapper class

@Olga_T Working on the wrapper class to get this resolved.

 

Watch a Video Interview
Top Kudoed Authors
Are You In?

Meet the Community Leaders!

SmartBear Connect is an excellent opportunity for training, in-person support, and networking.

GET YOUR TICKET WITH $100 OFF