Forum Discussion
Hi,
This is doable. But, you've not provided much detail or how you're trying to call the class. So instead, I've made a simple example that does nothing more than log a message.
Firstly, Groovy scripts/classes need to be added to the ReadyAPI/SoapUI install folders. SoapUI scans the scripts folders for new/changed scripts.
On my machine, I added these to.... \\\SmartBear\ReadyAPI-3.3.0\bin\scripts\groovyScripts
The filename is the name of the class with the .groovy extension. In this case, I have a file in the above folder named, "MyTearDownClass.groovy".
Below are the contents of that file...
package groovyScripts
class MyTearDownClass {
def logThePassedInMessge(log, message) {
log.info(message);
}
}
The package is important and must match the folder structure below \\\SmartBear\ReadyAPI-3.3.0\bin\scripts\
You can see if SoapUI can see and detect changes in your file by making a small change in your file and saving. Then switch to SoapUI and look at SoapUI Log
OK, now go to the Teardown script, my example is below....
tearDownObject = new groovyScripts.MyTearDownClass();
tearDownObject.logThePassedInMessge(log, "Hello from TearDown!");
And by either clicking the Teardown 'go' button or just the test case as a whole, I can see that this works by looking at the Script Log tab....