Runner.Stop Method

Applies to TestComplete 15.0, last modified on November 17, 2021

Description

Use the Stop method to stop the test execution. Unlike Runner.Halt, this method does not post messages to the test log.

Declaration

Runner.Stop(CurrentTestOnly)

CurrentTestOnly [in]    Optional    Boolean Default value: False   
Result None

Applies To

The method is applied to the following object:

Parameters

The method has the following parameter:

CurrentTestOnly

Specifies whether the method stops execution of the current test only or the whole test run.

Result Value

None.

Remarks

TestComplete generates the OnStopTest event when you stop the test run using the Runner.Stop method. You can create a handling routine for this event, to perform specific actions when the test stops.

Example

The following example demonstrates how to use the Runner.Stop method to stop the test execution if an error occurs.

JavaScript

function Test()
{

  try
  {
    // Performs testing actions
    …
  }
  catch(e)
  {
    // Posts an exception message to the test log
    Log.Error(e.message);
    // Stops the test execution
    Runner.Stop();
  }
  finally
  {
    // Performs finalization actions
    …
  }
}

JScript

function Test()
{

  try
  {
    // Performs testing actions
    …
  }
  catch(e)
  {
    // Posts an exception message to the test log
    Log.Error(e.description);
    // Stops the test execution
    Runner.Stop();
  }
  finally
  {
    // Performs finalization actions
    …
  }
}

Python

def Test():
  try: 
    # Performs testing actions
    # ...
    Log.Message("Running...")
  except Exception as e:
    # Posts an exception message to the test log
    Log.Error(e.description)
    Runner.Stop()
  finally:
    # Performs finalization actions
    # ...
    Log.Message("Sample Text")

VBScript

Sub Test

  Err.Clear
  On Error Resume Next

  ' Performs testing actions
  …

  If Err.Number <> 0 Then
    ' Posts an exception message to the test log
    Log.Error Err.Description
    ' Stops the test execution
    Runner.Stop

  Else
    ' Performs finalization actions
    …
  End If

End Sub

DelphiScript

procedure Test();
begin
  try
    // Performs testing actions
    …
  except
    // Posts an exception message to the test log
    Log.Error(ExceptionMessage);
    // Stops the test execution
    Runner.Stop;
  end;
end;

C++Script, C#Script

function Test()
{

  try
  {
    // Performs testing actions
    …
  }
  catch(e)
  {
    // Posts an exception message to the test log
    Log["Error"](e["description"]);
    // Stops the test execution
    Runner["Stop"]();
  }
  finally
  {
    // Performs finalization actions
    …
  }
}

See Also

Halt Method
Stop Execution Operation

Highlight search results