Stop and Rerun the Current Test Item After an Error

Applies to TestComplete 14.71, last modified on April 22, 2021

When you run tests (either test items specified on the Test Items page 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. On the Test Items page 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. On the Test Items page 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. 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.

TestComplete will proceed to the next test item

Stop and rerun current item

Click the image to enlarge it.

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

Exit сodes for rerun tests

If you automate your test runs via the command line or Jenkins, you may analyze the TestComplete exit codes to decide if your tests passed or not.

Regardless of the approach you use to rerun your test items, the exit code that the test runner returns corresponds to the status you see in the test log’s Summary page.

For example, if some retries failed, but the test finally passed successfully (all test items eventually passed), the TestComplete exit code will be 0 (passed without errors and warnings). For information about TestComplete exit codes, see TestComplete Exit Codes.

See Also

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

Highlight search results