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!
Hi,
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.