PriorInstanceMode Property

Applies to TestComplete 15.47, last modified on January 20, 2023
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

Use the PriorInstanceMode property to specify whether TestComplete should close the TestComplete or TestExecute instance running on the remote computer where the task will be executed.

Declaration

TaskObj.PriorInstanceMode

Read-Write Property Integer
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

The property can be one of the following values:

Constant Value Description
imError 0 TestComplete will display an error message and will not run the task.
imUse 1 The task will use the running instance of TestComplete (TestExecute). You can use this value in combination with the saNone value for the ActionAfterRun property in order to reduce the workload of the remote computer. In this case, after finishing the task, the remote TestComplete (TestExecute) instance will not be closed and it will be used for running the next task.
imTerminate 2 The remote instance of TestComplete (or TestExecute) will be restarted. Use this value to ensure that the task will not fail if previous tasks or test runs caused critical errors in the remote TestComplete (or TestExecute) instance.

Example

The following code snippet obtains a task, specifies that the remote instance of TestComplete will be restarted before executing the task and then launches the task.

JavaScript, JScript

function Test()
{

  var Task, TaskName;
  // Specifies the name of the task
  TaskName = "MyTask";
  // Obtains the task by its name
  Task = NetworkSuite.Jobs.ItemByName("MyJob").Tasks.ItemByName(TaskName);

  // Specifies that TestComplete will be used on the remote host
  Task.RemoteApplication = ra_TC;
  // Specifies that TestComplete on the remote host will be restarted before the task execution
  Task.PriorInstanceMode = imTerminate;

  // 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 task
  TaskName = "MyTask"
  # Obtains the task by its name
  Task = NetworkSuite.Jobs.ItemByName["MyJob"].Tasks.ItemByName[TaskName]
  # Specifies that TestComplete will be used on the remote host
  Task.RemoteApplication = ra_TC
  # Specifies that TestComplete on the remote host will be restarted before the task execution
  Task.PriorInstanceMode = imTerminate
  # 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 Task, TaskName
  ' Specifies the name of the task
  TaskName = "MyTask"
  ' Obtains the task by its name
  Set Task = NetworkSuite.Jobs.ItemByName("MyJob").Tasks.ItemByName(TaskName)

  ' Specifies that TestComplete will be used on the remote host
  Task.RemoteApplication = ra_TC
  ' Specifies that TestComplete on the remote host will be restarted before the task execution
  Task.PriorInstanceMode = imTerminate

  ' 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 Task, TaskName;
begin

  // Specifies the name of the task
  TaskName := 'MyTask';
  // Obtains the task by its name
  Task := NetworkSuite.Jobs.ItemByName['MyJob'].Tasks.ItemByName[TaskName];

  // Specifies that TestComplete will be used on the remote host
  Task.RemoteApplication := ra_TC;
  // Specifies that TestComplete on the remote host will be restarted before the task execution
  Task.PriorInstanceMode := imTerminate;

  // 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 Task, TaskName;
  // Specifies the name of the task
  TaskName = "MyTask";
  // Obtains the task by its name
  Task = NetworkSuite["Jobs"]["ItemByName"]("MyJob")["Tasks"]["ItemByName"](TaskName);

  // Specifies that TestComplete will be used on the remote host
  Task["RemoteApplication"] = ra_TC;
  // Specifies that TestComplete on the remote host will be restarted before the task execution
  Task["PriorInstanceMode"] = imTerminate;

  // 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
ActionAfterRun Property

Highlight search results