Stop and Rerun the Current Test Item After an Error

Applies to TestComplete 15.46, last modified on January 09, 2023

When you run tests (either test items specified on the Execution Plan editor or from the command line), by default, if an error occurs, TestComplete stops the entire project right after an error message is posted to the test log. It does not execute any other tests.

Sometimes you may need to change the default behavior to command TestComplete to rerun an unstable test item and then continue running the entire project. You can do it in one of the following ways:

Currently, the rerunning of BDD feature files is not supported.

Approach 1

  1. In the Execution Plan editor of your project, make sure that the On error property of a test item is set to Use project’s 'On error' property:

    Set the On error property to Use project's On error property

    Click the image to enlarge it.

  2. On the Properties page of your project, set the Playback> Error handling > On error property of your project to Stop and rerun current item. Use the Rerun failed test items property to set the number of retries for failed test items:

    Set the On error property of the project to Stop and rerun current item

    Click the image to enlarge it.

Approach 2

  1. In the Execution Plan editor of your project, set the On error property of your test item to Stop and rerun current item:

    Set the On error property to Stop and rerun current item

    Click the image to enlarge it.

    Note: The test item will ignore the Error handling > On error property of your project.

  2. On the Properties page of your project, specify the number of retries for failed test items by using the Playback> Error handling > Rerun failed test items property:

    Set the On error property of the project to Stop and rerun current item

    Click the image to enlarge it.

When you run your project and an error occurs in a test, TestComplete will rerun the problematic test item until it passes or until the maximum number of retries that the project’s Rerun failed test items property specifies is reached.

Test Results

If a retry passes successfully or with warnings, TestComplete will mark this test item as successful or warning respectively and add info about the number of retries to the Summary report.

If all rerun attempts fail, TestComplete will mark the test item as failed and proceed with the next test item.

Stop and rerun current item

Click the image to enlarge it.

Detailed information about successful retries is shown in the Warning and Passed tabs. By default, this information is grouped into a collapsed list marked with the icon for each rerun test item. You can expand such lists to obtain more information about each retry:

Stop and rerun current item

Click the image to enlarge it.

Exit codes for rerun tests

If your tests are run automatically (for example, by using the command line or from a CI system like Jenkins), you may want to get and analyze the TestComplete exit code to check whether your test run has passed or failed.

If your TestComplete project is configured to rerun failed test items, the exit code that TestComplete returns corresponds to the test session status you see in the Summary report. For instance, if a test item fails and then reruns successfully, the exit code will specify that the test session has been successful.

See Also

Controlling Test Execution Flow
About Controlling Test Execution Flow
Project Properties - Playback Options

Highlight search results