Passing Variables via Command Line

Applies to TestComplete 15.70, last modified on December 17, 2024

If you use project or project suite variables in your TestComplete tests, you can pass their values to tests via the command line.

To pass variable values via the command line, use the PrjVar (pv) or PSVar (psv) arguments for the project and project suite variables respectively.

Variable values you pass via the command line are temporary. At the beginning of the test run, they overwrite the initial value of appropriate variables of your project or project suite. After the test run is over, the variable values are restored to their initial state.
If the variable you set via the command line does not exist in your project or project suite, it will be created at the beginning of the test run and removed after the test run is complete.
If you run several projects that have a project variable with the same name, the command will set the variable value in all executed projects.

Example

Suppose, we have a test that uses the userName project variable to store the name of the current tested application’s user:

JavaScript, JScript

function MyTest()
{
  …
  var user = Project.Variables.userName;
  …
}

Python

def MyTest():
  …
  user = Project.Variables.userName
  …

VBScript

Sub MyTest()
  …
  user = Project.Variables.userName
  …
End Sub

DelphiScript

function MyTest();
var user;
begin
  …
  user := Project.Variables.userName;
  …
end;

C++Script, C#Script

function MyTest()
{
  …
  var user = Project["Variables"]["userName"];
  …
}

To run the test and set the variable value, the following command line can be used:

TestComplete.exe "C:\Work\My Projects\MySuite.pjs" /run /pv:userName=john.smith

Remarks

  • The name of a passed variable should include only alphanumeric characters ('A'..'Z', 'a'..'z' and '0'..'9') and underscores ('_') and does not start with a digit.

  • TestComplete treats variable values passed via the command line as strings. If the value includes spaces, enclose it in quotes.

See Also

TestComplete Command Line
About Project And Project Suite Variables
Passing Test Parameters via Command Line

Highlight search results