TestComplete lets you control the test run flow in several ways. If you run tests as test items, and the Stop on Error and Error Dialog playback options of your test project are disabled, then TestComplete does not stop the test item run when an error or exception occurs. It continues the test run and checks the result only after the test item run is over. If needed, you can change this behavior and stop the current test item right after an error occurs. To do this, follow these steps:
-
Open the project properties and select Playback on the list on the left of the page. Disable the Stop on error and Error dialog options. Otherwise, TestComplete stops the entire test run right after the first error or exception occurs.
-
Create the OnLogError event handler (to learn how to do this, see Creating Event Handlers for TestComplete Events). This event occurs every time TestComplete posts an error message to the test log. Using this event handler, you can catch the moment when an error occurs.
-
In the event handler, create test commands that will stop the current test item:
-
If you use scripts, add the following code to the event handling routine:
-
If you use keyword tests, do the following:
-
-
Open the Test Items page of the project editor and make sure that the Stop on Error property of all your test items is not equal to
Project
. Otherwise, TestComplete will stop the entire project.Note: The Runner.Stop(true)
script method and the Stop Execution operation stop the test item even if you set Stop on Error to None. It means that TestComplete will not run the test item’s further iterations and child test items.
See Also
Controlling Test Execution Flow
Stopping Tests on Errors and Exceptions - Overview
OnLogError Event
Runner.Stop Method
Stop Execution Operation