Errors that occur during the test run can be caused by accidental reasons. Such errors can occur a few times, and you may not want to interrupt your tests because of them. However, if a number of errors exceeds some limit, it will mean that something goes wrong and the test item should be stopped.
To configure your project to stop a test item when an error limit is reached and proceed with the next sibling test item:
Note: The approach we describe uses the Log.ErrCount
property that returns the number of errors that are posted during the current test item. To get the number of errors occurred during the entire project run, create and use a project variable as an error counter. To learn more about this approach, see Stop Project Run on the N-th Error.
-
If your project does not have the Events collection, add it:
Add an event control to the Events collection and create a handler for the OnLogError event:
-
Configure the event handler to compare the number of occurred errors with the number of “allowed” errors and stop the test item, if needed.
-
If you use scripts
Add the following code to the event handling routine:
-
If you use keyword tests
-
-
Open the Test Items page of the project editor and make sure that the On error property of all your test items are set to Continue running. Otherwise, TestComplete will stop the entire test run on the first error.
The
Runner.Stop(true)
script method and the Stop Execution operation stop the test item even if you set On error to Continue running. TestComplete will not run the test item’s further iterations and child test items.
See Also
Test Items Page (Project Editor)
Tests, Test Items, and Test Cases
StopOnError Property
StopOnException Property
Running, Rerunning, Pausing, and Stopping Automated Tests
Stopping Tests on Timeout