Forum Discussion

SumitM's avatar
SumitM
Occasional Contributor
6 years ago

Can we call Project level Tear down script from groovy test step?

Is there a way to call project level tear down script from any groovy script test step?

 

If yes, then can please some one show how to achieve it

2 Replies

  • groovyguy's avatar
    groovyguy
    Champion Level 1

    It is theoretically possible, but I have not figured out specifically how to make it work yet. You can use the following code:

     

    context.testCase.testSuite.project.runAfterRunScript();

    Which will not work, but that is due to the fact that it is expecting two arguments/parameters. I cannot figure out what to use for it, which are defined as: 

    1. com.eviware.soapui.model.testsuite.ProjectRunContext
    2. com.eviware.soapui.model.testsuite.ProjectRunner
    • groovyguy's avatar
      groovyguy
      Champion Level 1

      There might be a different way. You could retrieve the contents of the Project tear down script, and then evaluate/run that as a script.

       

      // Get the contents of the Tear Down Script at the Project level
      def script = context.testCase.testSuite.project.getAfterRunScript();
      
      // Execute the contents as a script
      new GroovyShell().evaluate(script)