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.
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
{
…
var user = Project.Variables.userName;
…
}
Python
…
user = Project.Variables.userName
…
VBScript
…
user = Project.Variables.userName
…
End Sub
DelphiScript
var user;
begin
…
user := Project.Variables.userName;
…
end;
C++Script, C#Script
{
…
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