Stopping Current Test Item After 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, and you do not want that the test will be interrupted because of them. But, if a number of errors exceeds some limit, it will mean that something goes wrong. This topic describes how you can stop the current test item when a certain number of error messages were posted to the log and continue 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 Stopping Project Run After the N-th Error.
  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. Create the OnLogError event handler (to learn how to do this, see Creating Event Handlers for TestComplete Events). This event occurs every time TestComplete posts an error message to the test log.

  3. In the event handler, create test commands that will compare the number of errors that occurred 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:

      Show Code

    • If you use keyword tests, do the following:

      Show Instructions

  4. Open the Test Items page of the project editor and make sure that the Stop on Error property of all your test items is not equal to Project. Otherwise, TestComplete stops the entire project.

    Specifying project's test items to None or Test Item
    Note: The Runner.Stop(true) script method and the Stop Execution operation stop the test item even if you set Stop on Error to None. It means that TestComplete will not run the test item’s further iterations and child test items.

See Also

Test Items Page (Project Editor)
Tests and Test Items
StopOnError Property
StopOnException Property
Running, Pausing and Stopping Automated Tests
Stopping Tests on Timeout

Highlight search results