You can run the entire test project or project suite, or individual automated tests. This topic explains how you can run automated tests from the TestComplete IDE. For other ways to run automated tests, see Running Tests.
Before running tests
You should 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.
Run tests
Run the entire project or project suite
Run tests by tags and tag expressions
Run a runnable project item (a low-level procedure, unit test and so on)
Run the entire project or project suite
-
Configure the test run order on the Test Items page of your project.
-
If needed, configure the project run order on the Test Items page of your project suite.
-
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:
-
If a project does not have project items, the test engine is unable to run it and shows the The project_name project cannot be run because there are no test items in it message. You can add test items to the project or select a test to run.
-
If the project suite does not contain projects or if all of the projects are excluded from the suite run, the test engine is unable to run the project suite and shows the The project suite cannot be run because there are no selected projects to be run message.
Run a keyword test
-
Right-click the needed script unit in the Project Explorer and select Run from the context menu.
– or –
-
Open the test in the Keyword Test editor and then click Run Test on the editor’s toolbar.
Run a script routine
-
Right-click the needed script unit in the Project Explorer and select Run | Run RoutineName from the context menu.
– 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>:
TestComplete will run all the tests that match the selected tag.
Run by a tag expression
-
Open the Test Items page of your project.
-
Add a new test item to it.
-
In the Execution entity column of the item, select the needed tag or select [Tag Expression]:
-
If the test item’s execution entry is set to [Tag Expression], in the Parameters column of the item, specify the needed expression:
-
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 Test Items Page (Project 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:
- In each project, assign the needed tags to the tests.
- In each project, create test items that will run the needed tests specified by their tags.
- On the Test Items page of your project suite, specify the needed project run order.
- 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.
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.
Note: | You cannot pause network suites (distributed tests) and low-level procedures. |
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:
-
in keyword tests - using the Stop Execution operation,
-
in scripts - using the
Runner.Stop
orRunner.Halt
method (the difference is thatStop
does not log an error).
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).
-
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:
See Also
Running Tests
Running Tests - Specifics
Specifics of Using TestComplete on Various Windows Operating Systems