Parameterizing Tests Using Variables

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

You usually use variables to store data and exchange data during the test run. TestComplete provides several types of variables that can be used in your tests: project and project suite variables. These variables are used to share data. They can store values between test runs and are shared between tests of various types included in your project or project suite, for instance, between scripts and keyword tests. You can also use project and project suite variables when you need to use the same data for more than one test. For more information on using the TestComplete variables, see About Variables.

You can use these variables to parameterize tests. That is, you can replace hard-coded input values in test commands and scripts with these special variables. Thus, the command that uses variables remains unchanged, but values within the command can change. This makes your tests easier to re-use with different data without having to modify commands.

You can also use variables to specify values of test parameters. Suppose, you want to call a keyword test with a parameter from another keyword test and specify the parameter value by using a project variable:

  1. Add the Run Keyword Test operation to the test. The Select Test dialog will appear.
  2. In the dialog, select the test to be run and click OK. The Operation Parameters dialog will appear.
  3. To assign the operation parameter value in the dialog, click the ellipsis button in the Value column. The Edit Parameter dialog will appear.
  4. In the dialog, do the following:
    • Choose Variable from the Mode drop-down list.
    • Specify the needed project variable in the Value edit box.
  5. Click OK in the Edit Parameter and Operation Parameters dialogs.

Using variables to specify test and routine parameters is convenient when the parameter values that should be passed to a test or a routine are changed during the test run and cannot be predicted.

Besides special project and project suite variables, you can also use global variables in scripts. You can use them within script routines or to specify routine parameters. Note that you cannot use global variables in keyword tests.

See Also

Parameterizing Tests
Parameterizing Keyword Tests
Parameterizing Script Routines

Highlight search results