Stop Project Run on the N-th Error

Applies to TestComplete 15.63, last modified on April 23, 2024

Errors that occur during the test run can be caused by accidental reasons. Such errors can occur a few times during the project run, and you may want not to stop the test because of them. However, if a number of errors exceeds some limit, it will mean that something goes wrong, and the current project must be stopped.

To configure your project to stop when an error limit is reached:

  1. Open the Variables page of your project and create an integer variable. Let’s call this variable ErrorCounter. It will store the number of errors occurred during the project run.

    Project variable
  2. If your project does not have the Events collection, add it:

    Add the Events collection to your project

    Add an event control to the Events collection and create a handler for the OnLogError event:

    Add the OnLogError event handler
  3. Configure the event handler to increase the project variable value and to stop the test run when the limit is reached:

    • If you use scripts

      Insert the following code into the event handling routine:

      Show Code

    • If you use keyword tests

      Show Instructions

  4. Open the Execution Plan editor of your project and set the On error property of all your test items to Continue running. Otherwise, the test run will be stopped on the first error.

    Set test item's 'On error' property

See Also

Controlling Test Execution Flow
About Controlling Test Execution Flow
OnLogError Event
Stop Method
Stop Execution Operation

Highlight search results