Forum Discussion

jwasiak's avatar
New Contributor
2 years ago

How to import custom groovy script library inside TestCase Teardown

I have Utilities class within my Utilities.groovy script within my project dir. 

I want to import this file inside TestCase Teardown script.

Is this even doable? My each try ends with "org.codehaus.groovy.control.MultipleCompilationErrorsException".

5 Replies

  • ChrisAdams's avatar
    Champion Level 3



    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) {


    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....




    • jwasiak's avatar
      New Contributor

      I'm using SoapUI 5.7.
      I have followed your sample and added the script under the same coresponding location here:
      C:\Program Files\SmartBear\SoapUI-5.7.0\bin\scripts\groovyScripts

      Then in newly created TestCase teardown script I added your code which at run gives me this error:

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script2.groovy: 1: unable to resolve class groovyScripts.MyTearDownClass @ line 1, column 18. tearDownObject = new groovyScripts.MyTearDownClass(); ^ org.codehaus.groovy.syntax.SyntaxException: unable to resolve class groovyScripts.MyTearDownClass @ line 1, column 18. at org.codehaus.groovy.ast.ClassCodeVisitorSupport.addError( at 
      • ChrisAdams's avatar
        Champion Level 3

        The above example was built using ReadyAPI 3.40.2.


        I have SoapUI 5.5.0, let me try there and I'll get back to you.