Forum Discussion

autoscout24's avatar
autoscout24
Contributor
16 years ago

'Run Test Case' - Groovy

Hi Support Team,
Could you guys please suggest me an idea, how I can use "Run Test Case" step via groovy script ?.
what is Important for me is the that option 'create a isolated copy for each run (Thread- safe)' - can I have this option in groovy , while calling the 'Run Test case' step ?

Regards
Vijay

5 Replies

  • Hello,

    Sure, any options set to the "Run TestCase" TestStep should be applied when running the TestStep from Groovy. To run it, use the following Groovy code:


    def testStep = testRunner.testCase.testSteps['Run TestCase']
    testStep.run( testRunner, context )


    This assumes that the "Run TestCase" TestStep is located in the same TestCase as the Groovy script calling it.

    Regards,
    Dain
    eviware.com
  • Hi Dain,
    Thanks for the reply. My requirement is different, I have testcase (eg. delete test case) defined globally and I have to call this test in all my test cases in tear down method with some parameters.

    TearDown_UpdateTestLink = testRunner.testCase.testSuite.project.getTestSuiteByName("GlobalMethods").testCases["DeleteCar"];
    TearDown_DeleteCar.setPropertyValue("VehicleID", 1212131);
    TearDown_DeleteCar.setPropertyValue("UserName", sTestCaseName);
    TearDown_DeleteCar.setPropertyValue("Password", sResult);

    runner3 = TearDown_DeleteCar.run( new com.eviware.soapui.support.types.StringToObjectMap(), false )


    The dis advantage is that when 2 test cases run in parallel, both calls the same global method at the same time, then one fails.

    do you have any solution to run thread safe.

    Regards
    Vijay
  • Hi all,
    Would be great, if some has got some idea on the question i asked.

    Regards
    Vijay
  • Hi,

    well you can add test case property runningDeleteCar which will indicate if tear down script is already running at that moment
    Than your code should look like this:

    while(context.expand( '${#TestCase#runningDeleteCar}' ) ){
    Thread.sleep(100)
    }
    testRunner.testCase.setPropertyValue("runningDeleteCar","true");
    TearDown_UpdateTestLink = testRunner.testCase.testSuite.project.getTestSuiteByName("GlobalMethods").testCases["DeleteCar"];
    TearDown_DeleteCar.setPropertyValue("VehicleID", 1212131);
    TearDown_DeleteCar.setPropertyValue("UserName", sTestCaseName);
    TearDown_DeleteCar.setPropertyValue("Password", sResult);

    runner3 = TearDown_DeleteCar.run( new com.eviware.soapui.support.types.StringToObjectMap(), false )

    testRunner.testCase.setPropertyValue("runningDeleteCar","false");


    Let us know does this helps.

    regards
    nebojsa
    eviware.com