API Masterminds - How do you reuse your ReadyAPI Groovy scripts?
How are you doing, API testers?
If you do a lot of Groovy scripting in ReadyAPI, you might have already come to a need to use the same scripts in different tests and projects.
Instead of copying over the same code snippets again and again, you, of course, thought about a way to have them all in one place from where you could easily access them from other scripts.
The ways to achieve this are:
-
Create custom Groovy classes, embed your reusable Groovy scripts into their methods, save them as separate files with the .groovy extension and voila - your Script Library is ready. You just need to point ReadyAPI where to find it (Preferences > ReadyAPI > Script library). If you change anything in those external classes, ReadyAPI will detect this and reload the classes automatically.
-
Convert your Groovy code to Java code and embed it into methods of Java classes. Once the classes are compiled and packed into a .jar file, you can point to it from ReadyAPI (Preferences > ReadyAPI > Custom Java libraries) and start calling your Java methods right from your Groovy scripts. Making changes in Java classes is more time-consuming than in Groovy classes as you need to re-compile them, but you may find it more convenient to share them with your co-workers when it’s just a single .jar file.
Questions:
-
Do you use script libraries or custom Java libraries to reuse parts of your ReadyAPI scripts?
-
And if so, what tasks are your reusable scripts for?