Forum Discussion

Keacey's avatar
Keacey
Contributor
17 years ago

Common teardown script for test cases

Hi,

I have created a groovy script for test case teardown. But since the script is  common for all test cases and i do not change anything in it, i copy-paste the same script for all the test case teardown.

Is there any way, by writing another groovy script (and probably running it initially before the i run the test cases), i can send this script to all the testcase teardown in a test suite? also can i write this script externally, maybe a .txt file and then import the content to the teardown script window.

Thanks in advance.
Kusuma.

3 Replies

  • omatzura's avatar
    omatzura
    Super Contributor
    Hi,

    you have several options:

    1) get soapUI Pro and package the script in the Script Library (read more at http://www.soapui.org/userguide/scripti ... pt_Library). Then make a call to this from within your teardown scripts.

    2) create a TestRunListener extension (read more at http://www.soapui.org/architecture/extensions.html) and implement the afterRun method to do you what you need. This will be run for all TestCases so remember to check that you are "within" the desired TestCase/TestSuite. If you use soapUI Pro, you can create the extension in groovy (and/or use the Script Library) with support for instant recompiling so you wont have to restart to reload changes to the extension.

    Hope this helps!

    regards,

    /Ole
    eviware.com
    • tech321's avatar
      tech321
      Contributor

      can you pleae provide an example of how to write a teardown script?

      • nmrao's avatar
        nmrao
        Champion Level 3
        tech321,
        What is your use case? Is it the same as original question or do you have something different use case?