TestedApps.TerminateAll Method

Applies to TestComplete 15.47, last modified on January 20, 2023

Description

The TestedApps.TerminateAll method terminates all tested applications. Use this method as a last resort, when the TestedApps.CloseAll method cannot close all applications.

This method only affects the applications started from a script (by TestedApp.Run, TestedApp.RunAs or TestedApps.RunAll) or from the corresponding context menu items of the Tested Applications project item. If the application was started manually (for example, via the Windows Explorer) it is not added to the list of tested applications and therefore is not terminated by the TestedApps.TerminateAll method.

Declaration

TestedApps.TerminateAll()

Result Boolean

Applies To

The method is applied to the following object:

Result Value

True, if all running instances of the tested applications were closed successfully; otherwise False.

Remarks

The TerminateAll method waits until each tested application process is terminated during the time period specified by the Auto-wait timeout setting.

To close any process in the system, use the Process.Close or Process.Terminate method.

Example

The following code snippet tries to close all running tested applications. If some applications are not closed successfully, the TestedApps.TerminateAll method is used to terminate them.

JavaScript, JScript

function Test()
{

  // Launches all tested applications
  TestedApps.RunAll();
  // Performs testing actions
  …
  // Closes the applications
  if (! TestedApps.CloseAll() )
    {
    // If TestComplete fails to close some applications, they are terminated
    Log.Warning("Some tested applications have not been closed successfully and will be terminated.");
    TestedApps.TerminateAll();
    }

}

Python

def Test():
  # Launches all tested applications
  TestedApps.RunAll()
  # Performs testing actions
  # ...
  # Closes the applications
  if not TestedApps.CloseAll():
    # If TestComplete fails to close some applications, they are terminated
    Log.Warning("Some tested applications have not been closed successfully and will be terminated.")
    TestedApps.TerminateAll()

VBScript

Sub Test

  ' Launches all tested applications
  TestedApps.RunAll
  ' Performs testing actions
  …
  ' Closes the applications
  If Not TestedApps.CloseAll Then
    ' If TestComplete fails to close some applications, they are terminated
    Log.Warning("Some tested applications have not been closed successfully and will be terminated.")
    TestedApps.TerminateAll
  End If
End Sub

DelphiScript

procedure Test();
begin

  // Launches all tested applications
  TestedApps.RunAll;
  // Performs testing actions
  …
  // Closes the applications
  if not TestedApps.CloseAll then
    begin
    // If TestComplete fails to close some applications, they are terminated
    Log.Warning('Some tested applications have not been closed successfully and will be terminated.');
    TestedApps.TerminateAll;
    end;

end;

C++Script, C#Script

function Test()
{

  // Launches all tested applications
  TestedApps["RunAll"]();
  // Performs testing actions
  …
  // Closes the applications
  if (! TestedApps["CloseAll"]() )
    {
    // If TestComplete fails to close some applications, they are terminated
    Log["Warning"]("Some tested applications have not been closed successfully and will be terminated.");
    TestedApps["TerminateAll"]();
    }

}

See Also

TestedApps.CloseAll
TestedApps.RunAll
Close Method
Terminate Method
Close Action (Process and Browser Objects)
Terminate Method (Process and Browser Objects)

Highlight search results