Run Method

Applies to TestComplete 15.70, last modified on December 17, 2024
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 Run method runs the given task. This will run the TestComplete project or project suite assigned to the task via the Task.ProjectPath property on the remote machine set via the Task.Host property. The project's test item that will be run is specified by the Task.Test property. See Running the Network Suite, Jobs and Tasks.

Declaration

TaskObj.Run(WaitForCompletion)

TaskObj An expression, variable or parameter that specifies a reference to a Task object
WaitForCompletion [in]    Required    Boolean    
Result None

Applies To

The method is applied to the following object:

Parameters

The method has the following parameter:

WaitForCompletion

Specifies whether the task will be run simultaneously with the entire script execution flow. If this parameter is False, the script execution will be suspended until the task's initialization finishes and resumed directly once the task is started. If WaitForCompletion is True, the script execution will be suspended until the execution of the task finishes.

Result Value

None.

Remarks

You cannot run the task, if a task of another job is running.

You cannot run the task from event handlers.

If you use network suite variables to exchange data between slave projects, run the tasks with the WaitForCompletion parameter set to True. Otherwise, the network suite variables may be shared among the projects incorrectly.

Example

The following script runs all tasks (except for the last one) belonging to the network suite's first job.

JavaScript, JScript

function Test()
{
  var Tasks = NetworkSuite.Jobs(0).Tasks;
  for (var i = 0; i < Tasks.Count - 1; i++)
    Tasks.Items(i).Run(true);
}

Python

def Test():
  Tasks = NetworkSuite.Jobs.Items[0].Tasks
  for i in range(0, Tasks.Count - 1):
    Tasks.Items[i].Run(True)

VBScript

Sub Test
  Set Tasks = NetworkSuite.Jobs(0).Tasks
  For i = 0 To Tasks.Count - 2
    Tasks.Items(i).Run(True)
  Next
End Sub

DelphiScript

procedure Test;
var Tasks, i : OleVariant;
begin
  Tasks := NetworkSuite.Jobs[0].Tasks;
  for i := 0 to Tasks.Count - 2 do
   Tasks.Items[i].Run(True);
end;

C++Script, C#Script

function Test()
{
  var Tasks = NetworkSuite["Jobs"](0)["Tasks"];
  for (var i = 0; i < Tasks["Count"] - 1; i++)
    Tasks["Items"](i)["Run"](true);
}

See Also

Distributed Testing
Running the Network Suite, Jobs and Tasks
Verify Method
Task.Stop
Task.ActionAfterRun
Task.State
Task.WaitForState
Task.ProjectPath
Task.Test
Task.Host

Highlight search results