Pass Environment Variables to TestComplete Tests

Applies to TestComplete 15.61, last modified on February 27, 2024

In your TestComplete projects you run as part of your pipeline or test plan, you may have tests that take environment data as input parameters. For example, you may have a test that takes the URL of your tested web application or the path to the test desktop application as an input parameter. When you run your pipeline or your test plan, you may want to pass these parameters to your TestComplete tests.

By default, the Visual Studio Test task cannot pass pipeline variables and task environment variables to TestComplete tests it runs via TestComplete test adapter, directly. There are several workarounds you can take:

Pass environment variable values as custom attributes

You can configure the Enable support for TestComplete tests task to start TestComplete (or TestExecute) on your agents with extra command-line parameters. You can use this to pass environment variables values to your TestComplete tests:

  1. Add the Enable support for TestComplete tests task to your pipeline.

    Note: If the task is not available, make sure that you have the TestComplete Test Adapter extension installed on your server. See Install TestComplete Test Adapter Extension.

  2. Configure the task to pass pipeline variables and local task variables to your TestComplete tests. To do this, you can use:

    Specifying an environment variable via test adapter

    Click the image to enlarge it.

  3. In your TestComplete test project, create a script routine (or a keyword test) that will get the project or project suite variables or values from the custom command-line parameters, and send them to your tests.

Store environment variable values to a file

  1. In your Team project, create a file that will store all needed parameter values.

  2. Place the file to a location where your TestComplete tests will be able to access it. For example, you can place the file to a repository and then configure your pipeline to place it to your test machine.

  3. Configure your pipeline to store parameter values to the file. You can do it, for example, by using the PowerShell script task or the Command line task:

    Saving an environment variable to a file

    Click the image to enlarge it.

  4. In your TestComplete test project, create a script routine (or a keyword test) that will get the needed values from the file and pass them to your tests. For detailed information on how to read data from files in TestComplete, see Working With External Data Sources.

See Also

Integration With Azure DevOps and Team Foundation Server via TestComplete Test Adapter
Link TestComplete Test Cases to Azure DevOps Test Cases
Install TestComplete Test Adapter Extension

Highlight search results