Test Property

Applies to TestComplete 15.31, last modified on March 17, 2022
The Network Suite functionality is deprecated. We don’t recommend using it for distributed testing. Consider using a CI/CD system for managing distributed tests. See Migrating Distributed Tests to CI/CD Systems for details. In case you need to run web tests on multiple environments in parallel, you can also try using your project’s Execution Plan.

Description

The Test property specifies the test item that the given task will run (the Test property of the task). This test item is part of the project or project suite whose path is specified in the task's ProjectPath property. To learn the format that must be used for the test item, see description of the task's Test property.

Declaration

TaskObj.Test

Read-Write Property String
TaskObj An expression, variable or parameter that specifies a reference to a Task object

Applies To

The property is applied to the following object:

Property Value

A string that represents the test item.

Example

The following code snippet obtains a task by its name, specifies the host on which the task will be run, sets the path to the project and specifies the test item that will be executed by the task. After that, it runs the specified task.

JavaScript, JScript

function Test()
{
  var JobName, TaskName, Task;
  // Specifies the name for the job to which the task belongs
  JobName = "MyJob";
  // Specifies the name of the task
  TaskName = "MyTask";
  // Obtains the task by its name
  Task = NetworkSuite.Jobs.ItemByName(JobName).Tasks.ItemByName(TaskName);

  // Specifies the host on which the task will be run
  Task.Host = NetworkSuite.Hosts.ItemByName("SlaveComputer1");

  // Specifies the path to the project the task will run
  Task.ProjectPath = "D:\\Distributed Testing\\Slave\\SlaveProject.mds";
  // Specifies the test item the task will run
  Task.Test = "Slave_Script\\Script\\Slave\\Main";

  // Runs the task
  Task.Run(true);
}

Python

def Test():
  # Specifies the name for the job to which the task belongs
  JobName = "MyJob"
  # Specifies the name for the task
  TaskName = "MyTask"
  # Obtains the task by its name
  Task = NetworkSuite.Jobs.ItemByName[JobName].Tasks.ItemByName[TaskName]
  # Specifies the host on which the task will be run
  Task.Host = NetworkSuite.Hosts.ItemByName["SlaveComputer1"]
  # Specifies the path to the project the task will run
  Task.ProjectPath = "D:\\Distributed Testing\\Slave\\SlaveProject.mds"
  # Specifies the test item the task will run
  Task.Test = "Slave_Script\\Script\\Slave\\Main"
  # Runs the task
  Task.Run(True)

VBScript

Sub Test

  Dim JobName, TaskName, Task
  ' Specifies the name for the job to which the task belongs
  JobName = "MyJob"
  ' Specifies the name of the task
  TaskName = "MyTask"
  ' Obtains the task by its name
  Set Task = NetworkSuite.Jobs.ItemByName(JobName).Tasks.ItemByName(TaskName)

  ' Specifies the host on which the task will be run
  Set Task.Host = NetworkSuite.Hosts.ItemByName("SlaveComputer1")

  ' Specifies the path to the project the task will run
  Task.ProjectPath = "D:\Distributed Testing\Slave\SlaveProject.mds"
  ' Specifies the test item the task will run
  Task.Test = "Slave_Script\Script\Slave\Main"

  ' Runs the task
  Task.Run(True)
End Sub

DelphiScript

procedure Test();
var JobName, TaskName, Task;
begin
  // Specifies the name for the job to which the task belongs
  JobName := 'MyJob';
  // Specifies the name of the task
  TaskName := 'MyTask';
  // Obtains the task by its name
  Task := NetworkSuite.Jobs.ItemByName[JobName].Tasks.ItemByName[TaskName];

  // Specifies the host on which the task will be run
  Task.Host := NetworkSuite.Hosts.ItemByName['SlaveComputer1'];

  // Specifies the path to the project the task will run
  Task.ProjectPath := 'D:\Distributed Testing\Slave\SlaveProject.mds';
  // Specifies the test item the task will run
  Task.Test := 'Slave_Script\Script\Slave\Main';

  // Runs the task
  Task.Run(true);
end;

C++Script, C#Script

function Test()
{
  var JobName, TaskName, Task;
  // Specifies the name for the job to which the task belongs
  JobName = "MyJob";
  // Specifies the name of the task
  TaskName = "MyTask";
  // Obtains the task by its name
  Task = NetworkSuite["Jobs"]["ItemByName"](JobName)["Tasks"]["ItemByName"](TaskName);

  // Specifies the host on which the task will be run
  Task["Host"] = NetworkSuite["Hosts"]["ItemByName"]("SlaveComputer1");

  // Specifies the path to the project the task will run
  Task["ProjectPath"] = "D:\\Distributed Testing\\Slave\\SlaveProject.mds";
  // Specifies the test item the task will run
  Task["Test"] = "Slave_Script\\Script\\Slave\\Main";

  // Runs the task
  Task["Run"](true);
}

See Also

Distributed Testing
Task.Run
Task.ProjectPath
Task.Host
Host.BasePath
NetworkSuite.SharedPath

Highlight search results