Occurs when a test run is over.
Declaration
| 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
-
It is not recommended to use global variables in the
OnStopTestevent handler. Typically, the scripting engine raises theOnStopTestevent 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 inOnStopTestevent handlers. -
Note for JScript, C++Script and C#Script users: Since the test script finishes by the moment the
OnStopTestevent 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
OnStopTestevent is not generated if the test is stopped right after it has begun. Also, theOnStopTestis not generated in Connected Applications.In all other cases, the
OnStopTestevent is generated when the test run is finished. For instance, if --- You call the
Runner.StoporRunner.Haltmethod. - 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.
- You call the
-
Do not call the
Runmethod of theNetworkSuite,JobandTaskobjects from the event handler. Otherwise, an error will occur.In addition, do not call the
NetworkSuite.Synchronizemethod from the event handler. The method will always return False.
See Also
OnStartTest Event
OnTimeout Event
Handling Events
Event Control
