Verify Method

Applies to TestComplete 14.71, last modified on April 22, 2021

Description

The Verify method checks if the given task can be executed by the network suite. Namely, it performs initialization actions described in Verifying Tasks, Jobs, Hosts and Network Suite.

Declaration

TaskObj.Verify()

TaskObj An expression, variable or parameter that specifies a reference to a Task object
Result Boolean

Applies To

The method is applied to the following object:

Result Value

True if the network suite can run the task, and False otherwise.

Remarks

The Verify method does not return the result until the network suite and all its tasks and jobs are in the Idle state. This is done to avoid certain problems which may occur when tasks that belong to different jobs run simultaneously. It is not recommended to run these tasks concurrently. Only tasks of the same job should be run concurrently.

Keep this feature in mind when calling tasks from script code. For instance, in the following code --

Task1.Run(false)
Task2.Verify()     //<- Verify waits until Task1 is over
Task2.Run()

-- Task2 will not run until the execution of Task1 is over, because the Verify method will block the further execution until Task1 is over. To run Task1 and Task2 concurrently, add them to the same job and then verify and run the job.

You cannot verify the task from the OnNetJobStateChange, OnNetSuiteStateChange and OnNetTaskStateChange event handlers.

Example

The following code snippet obtains a task and verifies it. If the network suite can execute the specified task, it runs the task. Otherwise, it posts an error message to the test log.

JavaScript, JScript

function Test()
{
  var Task;
  // Obtains the task
  Task = NetworkSuite.Jobs.ItemByName("MyJob").Tasks.ItemByName("MyTask");
  // Verifies the task and checks the results
  if (Task.Verify())
    Task.Run(true)
  else
    Log.Error("The verification has failed. The task will not be run.");
}

Python

def Test():
  # Obtains the task 
  Task = NetworkSuite.Jobs.ItemByName["MyJob"].Tasks.ItemByName["MyTask"]
  # Verifies the task and checks the results 
  if Task.Verify():
    Task.Run(True)
  else:
    Log.Error("The verification has failed. The task will not be run.")

VBScript

Sub Test
  Dim Task
  ' Obtains the task
  Set Task = NetworkSuite.Jobs.ItemByName("MyJob").Tasks.ItemByName("MyTask")
  ' Verifies the task and checks the results
  If Task.Verify Then
    Task.Run(True)
  Else
    Log.Error("The verification has failed. The task will not be run.")
  End If
End Sub

DelphiScript

procedure Test();
var Task;
begin
  // Obtains the task
  Task := NetworkSuite.Jobs.ItemByName['MyJob'].Tasks.ItemByName['MyTask'];
  // Verifies the task and checks the results
  if Task.Verify then
    Task.Run(true)
  else
    Log.Error('The verification has failed. The task will not be run.');
end;

C++Script, C#Script

function Test()
{
  var Task;
  // Obtains the task
  Task = NetworkSuite["Jobs"]["ItemByName"]("MyJob")["Tasks"]["ItemByName"]("MyTask");
  // Verifies the task and checks the results
  if (Task["Verify"]())
    Task["Run"](true)
  else
    Log["Error"]("The verification has failed. The task will not be run.");
}

See Also

Distributed Testing
Verifying Tasks, Jobs, Hosts and Network Suites
Task.Run
Host.Verify
Job.Verify
NetworkSuite.Verify

Highlight search results