How to run testcase and testsuite using Groovy in soapui?

12,021

I know this is super late to answer this question, but i will answer this so that it can help help seeking for help.

instead of Thread.sleep(3000), just use:

runner.waitUntilFinished()

Now it will wait until execution of step 1 get finished. Then it will start executing Step 2.

Share:
12,021
user3745193
Author by

user3745193

Updated on June 05, 2022

Comments

  • user3745193
    user3745193 almost 2 years

    i have some projects in soapui. i want to execute testsuites and testcases of these projects. i tried with this groovy code:

    //get test case from other project or from the same one
    project = testRunner.getTestCase().getTestSuite().getProject().getWorkspace().getProjectByName("Project1")
    testSuite = project.getTestSuiteByName("TestSuite 1 - Login");
    testCase = testSuite.getTestCaseByName("TestCase 1-Login");
    Thread.sleep(3000)
    testSuite2 = project.getTestSuiteByName("TestSuite3 - Report");
    testCase2 = testSuite.getTestCaseByName("TestCase1 - Report");
    
    // run test case
    runner = testCase.run(new com.eviware.soapui.support.types.StringToObjectMap(), false);
    Thread.sleep(3000)
    runner2 = testCase2.run(new com.eviware.soapui.support.types.StringToObjectMap(), false);
    

    When i run this groovy code, i have the following error message: java.lang.NullPointer.Exception cannot invoke method run() on null object for the last line

    runner2 = testCase2.run(new com.eviware.soapui.support.types.StringToObjectMap(), false);
    

    If i remove the last line it's working well.

    Any help please. Thank you