Run entire TestSuite from groovy
- 3 years ago
Hi LennSar ,
Here you go:
def targetTestSuite = testRunner.testCase.testSuite.project.getTestSuiteByName("yourTargetTestSuiteName") def targetTestCase = targetTestSuite.getTestCaseByName("yourTargetTestCaseName") targetTestSuite.run(new com.eviware.soapui.support.types.StringToObjectMap(), false) //targetTestCase.run(new com.eviware.soapui.support.types.StringToObjectMap(), false)
Hint: You can use the Objects available by default (see "i" info in the groovy test step on top right).
Based on these you can use the auto-complete while you write stuff. So for instance "testRunner.testCase.testSuite.project." and then press control+space you will see a list of useful commands.
It's a bit tricky somtimes to know what exactly is expected, example the ".run" shows you need 2 pass on 2 arguments, the StringToObjectMap and a Boolean.
I know for your use case these arguments (new com.eviware.soapui.support.types.StringToObjectMap(), false) do the trick, but don't ask me what exactly these mean 🙂
When you want to run another test step in the same test case as your groovy test step, the below will work: testRunner.testCase.getTestStepAt(0).run(testRunner, context)
This will run only the first test step and then continue your script.
If you want to repeat multiple test steps, you could use the below (but watch out you don't get stuck in an endless loop!).
I once reported a feature request to improve these javaDoc documentation, so it would be more straightforward to script, feel free to upvote 😉 :