Running Keyword Tests

Applies to TestComplete 15.64, last modified on May 16, 2024

This topic contains detailed information on the way you can execute keyword tests. It also contains links to topics that provide information on test parameters, variables, result values and explain how to comment operations out or uncomment them into the test.


In TestComplete, you can run keyword tests and execute individual operations of some test.

Keyword tests can be run as test items or they can be run from the Project Explorer. You can also execute them from the Keyword Test editor, from scripts or run them as part of another keyword test.

Individual operations can be run from the Keyword Test editor.

When executing keyword tests, the test engine runs operations one after another from from top to bottom of the test. You may temporarily exclude some operations from the execution order by disabling them. You can enable the operations later, if needed, and this way, include them into the test. See Enabling and Disabling Operations for more information on this.

Run as test items

You can run keyword tests as test items. To do this:

  • Select your project in the Project Explorer and then select View | Organize Tests from the TestComplete main menu. This will open the Execution Plan editor of the project.

  • Drag the desired keyword test from the Project Explorer to the Execution Plan editor.

  • Select File | Save from the TestComplete main menu to save the changes.

Now the keyword test will be executed when you run the project.

Run by tag

  1. In your tests, specify the needed tags. See Tags.

    Setting tags for a keyword test

    Click the image to enlarge it.

  2. Open the Execution Plan editor of your project.

  3. Click New Test Item to add a test item to the test run sequence.

  4. In the Execution entity column, click the ellipsis button. In the resulting Select Test dialog, in the Available Tests list, select the needed tag or select [Tag Expression].

    Selecting tags to run

    Click the image to enlarge it.

    Click OK to close the dialog.

  5. If you have selected [Tag Expression], click the ellipsis button in the Parameters column and specify the needed expression in the Test Parameters dialog.

    Specifying tag expression

    Click the image to enlarge it.

    Close the dialog.

Now, when you run your project or when you run the created test item, TestComplete will execute all the tests that match the specified tag or tag expression.

Run keyword tests under specified tags

Click the image to enlarge it.

Run from the Project Explorer

All keyword tests are shown under the KeywordTests node in the Project Explorer panel. To execute a test:

  • Right-click the desired test in the Project Explorer.

  • Choose Run Test_Name from the context menu.

Note: You cannot execute a keyword test in the described manner if this test has parameters that do not have default values specified.

Run from the keyword test editor

You can command TestComplete to execute a keyword test when you are editing the test in the Keyword Test editor. To do this:

  • Click Run on the editor toolbar.

-- or --

  • Right-click somewhere within the Test Steps page.

  • Choose Run Test_Name from the context menu.

Note: You cannot execute a keyword test in the described manners if this test has parameters that do not have default values specified.

To command TestComplete to resume the test run while debugging the test, right-click somewhere within the Test Steps page and choose Continue from the context menu.

Run individual operations or part of a test

To execute an operation:

  • Open the test that contains this operation in the Keyword Test editor. Activate the Test Steps page of the editor.

  • Right-click the operation in the test area.

  • Choose Run Selected Operation from the context menu.

    TestComplete will execute the selected operation.

The context menu also contains the Run From Selected Operation command. It executes the selected operation and the operations that follow it in the test (to the end of the test).

Run tests from scripts

You can run keyword tests from scripts. The statement that executes a test has the following syntax:

JavaScript, JScript

KeywordTests.Test_Name.Run(Param1, Param2, Param3 ...);


KeywordTests.Test_Name.Run(Param1, Param2, Param3 ...)


Call KeywordTests.Test_Name.Run(Param1, Param2, Param3 ...)


KeywordTests.Test_Name.Run(Param1, Param2, Param3 ...);

C++Script, C#Script

KeywordTests["Test_Name"]["Run"](Param1, Param2, Param3 ...);

Here KeywordTests is the name of the project item. Test_Name stands for the name of the desired test.

Run is the method that is used to execute keyword tests. The method does not return any value.

Param1, Param2 and so on are values of the test parameters (if the test has parameters). You should specify the values for parameters in the same order, in which the parameters are displayed on the Parameters page of the Keyword Test editor.

If the parameter has a default value, you may skip it in the call. If the parameter does not have a default value, it cannot be skipped.

If a test does not have parameters, just use the empty braces after the Run method name.

Run keyword tests from other keyword tests

To add a keyword test from another keyword test, use the Run Keyword Test operation. After you commanded TestComplete to add the operation to your test, TestComplete will display the dialogs, in which you can choose the test to be run and specify the parameters of this test (if it uses them).

Now when you run the “parent” keyword test, it will execute the inserted test. The result of the inserted test will become the result of the Run Keyword Test operation.

Note that a keyword test can run itself. In this case, we say that the test is run recursively. The recursion may be hidden. For instance, you may have a KeywordTest1 that runs the test KeywordTest2 and KeywordTest2, in its turn, runs KeywordTest1. Or even more complex: KeywordTest1 executes a code snippet that runs KeywordTest2, which runs a script routine, which, in its turn, runs KeywordTest1.

Recursive execution of tests may cause the stack overflow error. To avoid this, you should plan the execution sequence of tests carefully and use the If... Then operation to allow or forbid the recursive runs. In the simplest case, you can make the Run Keyword Test operation a child of the If... Then operation and use this If... Then operation to control whether the child Run Keyword Test operation should be executed or not.

See Also

Keyword Tests
Keyword Tests
KeywordTest Object
Run Method
Keyword Test Parameters
Setting and Checking a Keyword Test Result
Keyword Test Variables
Running Tests
Running Tests

Highlight search results