Forum Discussion

yassir's avatar
yassir
Occasional Contributor
9 years ago

retry failed testCase

i am facing an issue that should be easy to implement but somehow i can not find an answer anywhere, the goal is to retry failed test cases 3 times before mark the test Case as failed.

 

we have few pro version licenses just in case the solution requires the readyapi pro version.

 

  • yassir

     

    create a groovy script:

     

    if(testRun < 3)

    {

     

    testRunner.gotoStepByName("StepName")

     

    }

    • yassir's avatar
      yassir
      Occasional Contributor

      prashobkt thank you very much for your input. i was able to get this to work by using below code but now after i was able to get test case to rerun i am facing another issue to set status to Finished instead of Failed.

      the rerun is passing but test case still showing failed in result. i am using testCaseResult.setStatus but it doesnt seem to work so far

       

       

      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 <3; i++) {

       

                                                                testCaseResult.testCase.run(null, false)

                                                 }

       

                                   }

      }

       

      • prashobkt's avatar
        prashobkt
        Contributor

        yassir

         

        I would suggest to use a custom property to store and write the test case result.