Forum Discussion

Sam19's avatar
Sam19
New Contributor
7 years ago

Run test case again if it fails and it should stop after pass using tear down script at testsuite le

I have 80 test cases in a testsuite and If I am running all the cases in one go(running test suite).
My Requirement is to write down a script in Tear Down which should run failed test cases one by one(each test case n number of times) and If any test case pass in between then test runner should move to the next failed test case

1 Reply

  • Sam19's avatar
    Sam19
    New Contributor

    I have Achieved it by following code where failed test cases run in Serial

     

    def reRunCount = Integer.parseInt(testSuite.getPropertyValue("RerunCount"))
    log.info reRunCount
    for ( testCaseResult in runner.results )
    {
    testCaseName = testCaseResult.getTestCase().name
    log.info testCaseName
    if ( testCaseResult.getStatus().toString() == 'FAILED' )
    {
    log.info "$testCaseName has failed"
    for (i = 0; i < reRunCount; i++)
    {
    def tRun = testCaseResult.testCase.run(null, false)
    log.info tRun.getStatus()
    if(tRun.getStatus().toString() == "FINISHED")
    {
    break;
    }
    if(tRun.getStatus().toString() == "FAILED" && i == 0)
    {
    for( testStepResult in tRun.results )
    {
    if(testStepResult.getStatus().toString() != "OK")
    {
    log.info "TestStep [" + testStepResult.testStep.name + "] finished with status " + testStepResult.getStatus().toString()
    testStepResult.messages.each() { msg -> log.info msg }
    }
    }
    }

    }
    }

    }

     

    But I want to run the failed test case in parallel

    Any help??