Forum Discussion

kowcik's avatar
kowcik
Occasional Contributor
7 years ago

I want to re-execute the failed test cases automatically once i run suite wise

Hi Team

 

I am running the test cases through testRunner from test suite. My need is to re-execute the failed test cases at the same instance.

can u please help me out 

2 Replies

  • StevenColon's avatar
    StevenColon
    SmartBear Alumni (Retired)

    Thank you for posting to our Community Forum. 

     

    You can add the below script to the TestSuite TearDown Script section to rerun any TestCases that have failed. 

     

    //in Test Suite TearDown Script
    
    for ( testCaseResult in runner.results ) {
    
        testCaseName = testCaseResult.getTestCase().name
    
        log.info testCaseName
    
     
    
    	if ( testCaseResult.getStatus().toString() == 'FAILED' ){
    		log.info "$testCaseName has failed"
    		testCaseResult.testCase.run(null, false)
    	}
    }

    Have a great day! 

    • kowcik's avatar
      kowcik
      Occasional Contributor

      Thanks for your update. It really worked. But the issue now is, all my failed cases are executed but the status of test is still fail even all the test cases are passed.

       

      When i look into junit reports, the test case that got passed in reexecution still shown as fail..

       

      Can u help us in this ?