Forum Discussion

RajeshVV's avatar
RajeshVV
Contributor
8 years ago

How to rerun a failed test item for a given iteration count.

I tried using a skip variable if the item passes and then execute the next item. 

Whereas, if test item fails the iterator does not work and execution continues to the next item in the list.

 

I've used "Runner.Stop(True)" to stop execution if the test fails at any point, rather than enabling the "Stop on error" setting

Also, to ignore the current test case if it is already passed in the first iteration

 

Code Snippet to skip if test case is passed which will ignore the iteration (if iteration count is more than 1)

 

 

Function SkipExecutionifPASS(TestCaseName)
          ResultfromPreviousRun = GetTcResult(TestCaseName)
If ResultfromPreviousRun = "PASS" then
        Log.Message(TestCaseName&" is skipped")
        Runner.Stop(True)
End If
End Function

 

How can I instruct TC to execute the failed test case till the maximum iterations defined from the "Count" setting in project "Test Items" screen

 

-Rajesh VV

 

 

  • I don't think TC have that ability to do that as it is kind of Custom requirement.

     

    What you can do is, Instead of doing this thru TestItem you can create a Custom function that controls this execution.

  • shankar_r's avatar
    shankar_r
    Community Hero

    Without knowing your flow to execute the test, can't answer this question as it is related the execution flow scenario.

    • RajeshVV's avatar
      RajeshVV
      Contributor

       

      'TestItem1 - Test1 - Set to execute 3 Iterations
      'TestItem2 - Test2 - Set to execute 3 Iterations
      
      
      Sub Test1
      
          Log.Message "Pass"
          Log.Error "Fail"
          Log.Checkpoint "Success"
      
      End Sub
      
      Sub Test2
      
          Log.Message "Pass"
      
      End Sub

       

       

      From the above two routines, when error occurs it should re-run the TestItem1 from the beginning instead of executing the 

      Log.Checkpoint "Success" statement

       

      shankar_r Re-run should happen only for the given set of iterations set from 'Count' setting in the Test Items window

      • shankar_r's avatar
        shankar_r
        Community Hero

        I don't think TC have that ability to do that as it is kind of Custom requirement.

         

        What you can do is, Instead of doing this thru TestItem you can create a Custom function that controls this execution.