Forum Discussion

tomovermeers's avatar
Occasional Contributor
7 years ago

Launch teststep automatically from groovyscript

I am new to SoapUI. This is the groovyscript I wrote. But now I want to launch a teststep called "isAlive-SoapCall" in a TestCase "Sanity-TC" in a TestSuite "Sanity-TS". So while i loop and change every time the endpoint I want to execute this one teststep and maybe log the result to be sure the teststep is executed in the 6 different environments. How can I achieve this? I would like to know also where i place the groovyscript in my soapui-project. Do not forget that I am a junior who has everything still to learn. Thanks in advance.

def environments = ['tt':'10', 'dv':'20', 'qa':'30', 'pp':'40', 'pr':'50', 'tr':'60']
		environments.each{environment , url -> testRunner

3 Replies

  • avidCoder's avatar
    Super Contributor

    I think, you should write code step by step. Use below code:-


    project = testRunner.getTestCase().getTestSuite().getProject().getWorkspace().getProjectByName("Your Project Name")
    testSuite = project.getTestSuiteByName("Sanity-TS");
    testCase = testSuite.getTestCaseByName("Sanity-TC")
    testS = testCase.getTestStepByName("isAlive-SoapCall")


    Hope it helps.

  • JHunt's avatar
    Community Hero

    You're probably after runTestStepByName (in com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner).


    You're also over complicating it, I think, but then I don't know your project.


    Take a look at the picture attached for how I would achieve a similar result.


    And see my post here that explains how to use a TestRunContext:

  • JHunt's avatar
    Community Hero

    I wasn't aware you could get the key and value for a MapEntry as a parameter in a Closure passed to each. I always ended up writing "it.key" and "it.entry", which was a bit painful, so thanks for that.


    I think I need to start writing collect more often since I tend to overuse each.


    You may find the attached answer an improvement over my last one.