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.
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.
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())
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:
Do Like and accept if you find it as solution.