Stopping Project Run After the N-th Error

Applies to TestComplete 12.60, last modified on September 17, 2018

Some errors can be caused by accidentally reasons. Such errors can occur a few times during the project run, and you may want not to stop the test because of them. But, if a number of errors exceeds some limit, it will mean that something goes wrong, and the current project must be stopped. This topic describes how you can stop the entire project run when the specific number of errors occurs. To do this, perform the steps below.

  1. Open the project properties and select Playback on the list on the left of the page. Disable the Stop on error and Error dialog options. Otherwise, TestComplete stops the entire test run right after the first error or exception occurs.

    Disable the project's 'Stop on Error' and 'Error Dialog' playback options.
  2. Open the Variables page of the project editor 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
  3. Create the OnLogError event handler (to learn how to do this, see Creating Event Handlers for TestComplete Events). This event handler will be used to count every error that is posted to the test log during the test run.

  4. In the event handler, create test commands that will increase the project variable, and when it reaches the limit, stop the current test item. To do this:

    • If you use scripts, insert the following code into the event handling routine:

      Show Code

    • If you use keyword tests, do the following:

      Show Instructions

  5. Open the Test Items page of the project editor and set the Stop on Error property of all your test items to Project. It allows you to stop the entire project when the test item is stopped.

    Set test item's 'Stop on Error' property
  6. Open the Test Items page of the project suite editor and disable the Stop on Error property of the current project. Otherwise, TestComplete will stop the project suite.

    Disable test item's 'Stop on Error' property

See Also

Controlling Test Execution Flow
Stopping Tests on Errors and Exceptions - Overview
OnLogError Event
Runner.Stop Method
Stop Execution Operation

Highlight search results