Forum Discussion

MPleas's avatar
MPleas
Occasional Contributor
10 years ago

Run TestCase from Groovy isn't returning properties

Hi! We are implementing an external data source for use with our SoapUI Pro tests. Our current plan is to have each test have the first step be a Groovy step that is basically the manager of the test. The SoapUI test will be designed just like any normal test, the exception is that it will have this first Groovy step. The Groovy step will grab the data from the external data source. The Groovy step is going to execute all of the steps in the SoapUI test through the Groovy script. This allows us to control the data, looping, etc. The Groovy step will basically iterate through all of the steps in the test and run them. At the end of the Groovy script it cancels the run since all steps were run by the Groovy script and we don't want the steps to run again.

This works great and does what we want, except for when the test step is "Run TestCase" step. The test step is setup to return properties back to the calling test. However, these properties are not being returned back to the test.

Basically we're using s.run( testRunner, context ) to run the step that is the 'Run TestCase' step.

At the end of the Groovy script it uses testRunner.cancel to end the test. This is because the initial Groovy step went through and executed each of the steps via the Groovy step and we don't want them to run again.

I'm wondering if it's this testRunner.cancel within the called test that is causing the properties not to return back to the test? Is there another way of ending the test via Groovy script without 'cancelling'? It doesn't appear that there is a 'finish' method or 'break' method that would allow the test to finish without 'cancelling' it.

2 Replies

  • MPleas's avatar
    MPleas
    Occasional Contributor
    It doesn't look like it's the .cancel that is preventing the properties from returning to the calling test.

    I put a final step in the test that is just a Groovy test step called 'End'. There is nothing in it. Instead of doing testRunner.cancel, I did testRunner.gotoStepByName("End") to skip to the end after it executes them all through the Groovy step. Even after removing the testRunner.cancel, the properties are still not being returned to the calling test.

    Should executing a "Run TestCase" step via Groovy return the properties? Is there something I'm not doing correctly in the call to the step?
  • MPleas's avatar
    MPleas
    Occasional Contributor
    This turned out to be two issues: 1) Problems with our code. 2) In all the tweaking we'd done we'd been changing all kinds of settings trying to get it to work. The run selection for the "Run TestCase" options needs to be set at : "Run primary TestCase (wait for running to finish, Thread-Safe)". Since we're executing all of the steps via Groovy, this option needs to be set in order for it to properly wait for it to be finished.