OnStopTest Event

Applies to TestComplete 15.20, last modified on January 19, 2022

Occurs when a test run is over.

Declaration

OnStopTest(Sender) Parameters
Sender [in] Required Variant

Description

Occurs when TestComplete stops running a test, namely --

  • When execution of any test in your project, for example, a script routine or a keyword test, is stopped.
  • When execution of any project test item is stopped (regardless of whether you run individual test items or the entire project). If tests are organized into batches, the event will be fired for each test item.

You can create an OnStopTest event handler to perform actions after the test execution is finished. For instance, the event handler can play sounds to indicate that the test execution has finished.

Parameters

The event has the following parameter:

Sender

The Event control that processes the event.

Remarks

  • If a test is stopped on error, the event handler will ignore any commands that start a new run, for instance, KeywordTest.Run.

  • It is not recommended to use global variables in the OnStopTest event handler. Typically, the scripting engine raises the OnStopTest event when these variables already have been cleared and are not available to your scripts. To avoid possible issues, we recommend that you use project variables rather than global script variables in OnStopTest event handlers.

  • Note for JScript, C++Script and C#Script users: Since the test script finishes by the moment the OnStopTest event handler starts, the objects created by the script become invalid. If you store a reference to an object in a global script variable or in a project variable, it will refer to an invalid object and your script will cause the Can't execute code from a freed script error, even if the object is not null.

    To work around the issue, create the object anew within your handler routine. If the object contains data that you need to use, you need to save this data to project variables, file or some external COM object.

  • The OnStopTest event is not generated if the test is stopped right after it has begun. Also, the OnStopTest is not generated in Connected Applications.

    In all other cases, the OnStopTest event is generated when the test run is finished. For instance, if --

    • You call the Runner.Stop or Runner.Halt method.
    • During test execution, you press the Stop or Pause button on TestComplete toolbars and menus.
    • During test execution, you press the shortcut that corresponds to the Stop button.
    • An exception occurred during the script execution.
  • Do not call the Run method of the NetworkSuite, Job and Task objects from the event handler. Otherwise, an error will occur.

    In addition, do not call the NetworkSuite.Synchronize method from the event handler. The method will always return False.

See Also

OnStartTest Event
OnTimeout Event
Handling Events
Event Control

Highlight search results