Running Tests

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

Before running tests

Run automated tests in an environment with proper initial conditions to avoid possible errors due to environment inconsistencies. For example:

  • If a test runs the application, make sure that the application is not already running.

  • If a test works with an already running application, make sure the application is in the right state for the test.

  • If a test creates files, make sure these files do not already exist.

  • And so on.

If needed, add the appropriate commands at the beginning of the test to create proper initial conditions.

Running tests

From TestComplete IDE

Run the entire project or project suite
  1. Configure the test run order in the Execution Plan editor of the project.

  2. If needed, configure the project run order on the Test Items page of your project suite.

  3. Select Run Project or Run Project Suite from the Test menu.

    – or –

    Select Run > Run Project or Run > Run Project Suite from the Test Engine toolbar.

Notes:

Run a keyword test
  • Right-click the needed test in the Project Explorer and select Run from the context menu.

    Running a keyword test

    Click the image to enlarge it.

– or –

  • Open the test in the Keyword Test editor and then click Run on the editor’s toolbar.

    Running a keyword test

    Click the image to enlarge it.

Run a script routine
  • Right-click the needed script unit in the Project Explorer and select Run | Run RoutineName from the context menu.

    Running a script routine

    Click the image to enlarge it.

– or –

  • In the Code Editor, place an insertion point inside the routine code and then click Run This Routine on the Code Editor’s toolbar.

Note: This works only for script routines that have no parameters. Routines with parameters can be called only from other tests, because you need to specify parameter values.
Run tests by tags and tag expressions

Note: Keyword tests, script functions and BDD tests might have tags assigned to them. You can run tests by tags, that is, you can specify a tag or a tag expression, and the test engine will run all the tests that match this tag or tag expression.

Run by a tag

Assign tags to your tests. To learn how to do that, see Script Test Tags, Tags, and BDD Test Tags.

Right-click your project in the Project Explorer, and then click Run @<tag_name>:

Running tests under a tag

Click the image to enlarge it.

TestComplete will run all the tests that match the selected tag.

Run by a tag expression

  1. Open the Execution Plan editor of the project.

  2. Add a new test item to it.

  3. In the Execution entity column of the item, select the needed tag or select [Tag Expression]:

    Setting a test item to a tag or tag expression

    Click the image to enlarge it.

  4. If the test item’s execution entry is set to [Tag Expression], in the Parameters column of the item, specify the needed expression:

    Specifying a tag expression

    Click the image to enlarge it.

    Tag expression syntax

  5. Run the created test item or run the entire project (see above). TestComplete will run all the tests that match the selected tag or tag expression.

Note: TestComplete will run the tests that match the specified tag or tag expression in an arbitrary order. If the test execution order matters, create an explicit test run sequence for your project instead. See Execution Plan Editor.

Tip: Tags are project-specific. They are not shared among projects that belong to the same project suite. If in your project suite you have several projects whose tests you want to combine into a single run based on their tags, you can do the following:

  1. In each project, assign the needed tags to the tests.
  2. In each project, create test items that will run the needed tests specified by their tags.
  3. On the Test Items page of your project suite, specify the needed project run order.
  4. Run the entire project suite.
Run a runnable project item (a low-level procedure, unit test and so on)
  • Right-click the item in the Project Explorer and select Run from the context menu.

Run a test that was launched last
  • Select Run > Repeat Last Run on the Test Engine toolbar.

Rerun tests

You can configure TestComplete to rerun failed tests:

  1. Set the project Playback > Error handling > On error property to Stop and rerun current item.

    – or –

    In the Execution Plan editor of the project, set the On error property of your test items to Stop and rerun current item. In this case, the test items will ignore the Playback > Error handling > On error property of your project.

  2. Specify the number of retries for failed test items by using the project Playback > Error handling > Rerun failed test items property.

For complete information, see Stop and Rerun the Current Test Item After an Error.

Pause test runs

To pause a running automated test, do one of the following:

  • Click the button on the TestComplete indicator.

  • Press Shift+F10 (the shortcut can be changed in the Global Shortcuts dialog).

  • Click Pause on the Debug toolbar.

When a test is paused you can:

  • Debug the test: step through it, view variable values and so on.

  • View the current test log (if the Show Log on pause option is enabled).

Resume test run

To resume a paused test, do any of the following:

  • Click the button on the TestComplete indicator.

  • Press Shift+F3 (the shortcut can be changed in the Global Shortcuts dialog).

  • Click Run on the Test Engine toolbar.

  • (For keyword tests only) Right-click within the Keyword Test editor and choose Continue from the context menu.

Stop a test

To stop the test before it completes, do any of the following:

  • Click the button on the TestComplete indicator.

  • Press Shift+F2 (the shortcut can be changed in the in the Global Shortcuts dialog).

  • Click Stop on the Test Engine toolbar.

TestComplete lets you stop tests on timeout and on errors. For more information, see Controlling Test Execution Flow.

You can also stop the test run from the test itself:

Other ways to run tests

Stop tests on errors and exceptions

By default, if an error occurs during the test run (for example, a tested object is not found), TestComplete posts information about it to the test log and stops the test run. Also, if an unhandled exception occurs in your script test (for example, the list index is out of bounds), TestComplete shows an error message and stops the test run. You can change this behavior to handle errors in the way you need. You can configure TestComplete to do the following:

  • Ignore any errors and continue the test run.

  • Stop the current test and proceed with the next test (applicable, for example, when running a project or when running tests by tags).

  • Stop and rerun the current test.

  • Stop the test run when an error limit is reached.

  • Stop the test run only when a specific error occurs.

To learn how to do this, see Controlling Test Execution Flow.

Test playback options

You can change the mouse movement and text input speed, default object waiting timeout and other playback options in your TestComplete project properties. For a description of available options, see:

Project Properties - Playback Options

See Also

Testing With TestComplete

Highlight search results