Running Keyword Tests

Applies to TestComplete 14.10, last modified on June 5, 2019

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.

Basic Concepts

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.

Running Tests 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 Test Items page of the project editor.

  • Drag the desired keyword test from the Project Explorer to the Test Items 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.

Running Tests 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.

Running Tests 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 Test from the toolbar that is shown in the Test Steps page of the editor.

-- 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.

Running 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).

Running 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 ...);

Python

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

VBScript

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

DelphiScript

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.

Running 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.

Related Topics of Interest

Keyword Test Parameters

Explains how you can parameterize the test runs.

Setting and Checking a Keyword Test Result

Describes how to obtain and check the test result.

Keyword Test Variables

Explains how you can use variables in your keyword tests.

Enabling and Disabling Operations

Explains how to temporarily exclude some operations from the test and how to include them back again.

See Also

Keyword Tests
Keyword Testing - Overview
KeywordTest Object
Run Method
Keyword Test Parameters
Setting and Checking a Keyword Test Result
Keyword Test Variables
Running, Pausing and Stopping Automated Tests
Running Tests

Highlight search results