Forum Discussion

QSuper_Limited_'s avatar
QSuper_Limited_
Occasional Contributor
12 years ago

[RES]Set Project Level TestSuites Teardown script via Groovy

Hi,

We have a groovy teardown script content that need to be set automatically when the project is created. The teardown script needs to be placed into the "Teardown Script Tab" of the TestSuites tab at the project level as a part of yet another groovy code that creates the project. Please let us know how to go about it? It would be great if we can have snippet of the code that can do this? Please check the attached screenshot for location where the script content needs to go in.
  • Hi,

    From what I have understood, there is no out of the box feature which will paste the script in the teardown script editor. why don't you manually copy paste the script in the teardown script box. If there are too many test suites you can use event handler which is set on the project level so it will run after the testSuite is run in project.
    http://www.soapui.org/Scripting-Properties/custom-event-handlers.html

    You can use TestSuitRunListener.afterRun

    Thanks,
    Jeshtha
  • QSuper_Limited_'s avatar
    QSuper_Limited_
    Occasional Contributor
    Thanks so much, Jeshtha.

    However, we have coded a project builder in groovy, and would like to have this feature as part of the automation. Since, there is no means to do this per se, is there a way I can map an external script (a script file, might be ) to be triggered following the testsuite execution's completion to run as a teardown script at project level?

    Thanks once again.

    - Vik
  • Hi,
    If I understand correctly - you are creating the project and test suites through groovy scripts.
    If so - you can use
    project.setAfterRunScript( script);
    method to set the tear down script at the location which you have mentioned, link to javadoc: http://www.soapui.org/apidocs/com/eviwa ... .String%29. Just to make it clear - this script will run only once after all the test suites are executed.

    If you want to set the tear down script for individual test suite then use
    testSuite.setTearDownScript( script )
    , javadoc: http://www.soapui.org/apidocs/com/eviwa ... .String%29.

    I hope this helps.

    Best Regards,
    Prakash
    SmartBear Sweden