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
Solved! Go to Solution.
'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
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.
I had the same problem and I can present my solution:
All my testcases are defined in the testitems- view in the project. Additonaly I have created two additional Folders: "Retest1" and "Retest2". The tests are executed with "Testexecute".
I have created a powershell- script, that makes a checkout from GIT and starts the tesexecution. So far so good.
In a second step i have modified the event handlers. Whenever an error in a testcase is raised I set a value, that the testcase has failed. If it is passed no flag is setted. This flag is written to a csv- file, like: "TCSName","Result".
After the testrun is completed the powershell script analyses the csv. Each testcase that has the flag "failed" is copied into the ".mds" - file in the tag "Retest1". After all items are identified the exectuion will be restarted, but only the testitem "Retest1".
I don't know if this approach is the best, but it works very well for us.
I execute my tests with testexecute and not
@maxtester I want to achieve the exact same results which you have done.
Could you please help me with some more details?
How to copy failed test cases to .mds file?
How to then re-run the execution with only the failed test cases?