How to use method defined in separate groovy script in different test suite
Hi, I'm new to ReadyApi, would like to create a public method in a test project that can be used by any testSuite/testCase/testStep, how can I achieve this?
Thanks for help!
Solved! Go to Solution.
You can kind of do this, but the script is not 'inside' the SoapUI GUI.
What you can do is create a Groovy class in a text file. This text file needs to be in the SoapUI folder structure. Then, within a Groovy test step in your test, you can instantiate an object of your class and call methods upon it.
This link on Scripting from Smartbear's own site shows you how.
I've used this functionality extensively. Before I 'discovered' this, what I had were lots of tests including steps that had the same script assertion. Maintaining this was a massive pain. When I found about the external scripts folder, I wrote my assertion in a groovy class file in the external scripts folder. I modified my tests by removing the duplicated script assertion and instead call the external groovy class. This meant if I had to change the assertion, then I only had to edit the external file.
Thanks for the reply.
Is there way to save the script in the same test project? (so that many people can easily get shared of it and all files are in the same git repo)
I think therein lies the difficulty. SoapUI looks within its own app structure to find and compile the external scripts.
I do remember a similar question about putting the scripts with the tests so that they could be put into the source code repository.
You might want to check the SoapUI options, there may be an option to change the default scripts folder, but I'm at home now, so I cannot check.