The TestComplete behavior in case of an error depends on the test project’s settings and the types of running tests. By default, TestComplete stops the entire test run when an error or exception occurs. If needed, you can change this default behavior and continue the test run. For example, you can command TestComplete to stop only the current project test item and continue the run with the next sibling test item. This topic describes common ways of handling the test run flow in case of an error.
Stopping the Entire Test Run When an Error or Exception Occurs
Stopping the Test Run After the Current Test Item Fails
Stopping the Project Suite Test After the Project Test Fails
Stopping the Entire Test Run When an Error or Exception Occurs
During a test run, you may need to interrupt the entire test run after an error or an exception occurs. In order to do this, use the project’s Stop on error and Error dialog playback options. You can find them on the Properties page of the project editor.
The Stop on Error and Error Dialog options affect the behavior of the test engine in case of an error or exception occurs, respectively. By default, these options are enabled so that whenever an error or exception is encountered, TestComplete stops the test run or shows a dialog informing you about the problem.
If the options are disabled and an error or exception occurs, TestComplete simply continues running the test until it gets another command. When the test is over, you will be able to view all the errors that occurred during the test run in the test log.
Stopping the Test Run After the Current Test Item Fails
When you run a project test, the test engine runs test items that are specified on the Test Items page of the project editor. If an error occurs, and if the project’s Stop on Error or Error dialog option is disabled, TestComplete will perform the following actions:
-
It will continue the test run until the current test item run is over.
-
After that, it will search for error messages in the test item’s test log.
-
If the log contains error messages, the test engine will perform an action according to the value specified in the Stop on error or Stop on exception property:
The Stop on error or Stop on exception property can store one of the following values:
-
Test Item - (Default) If this value is selected and an error or an exception occurred during the test item run, TestComplete will stop the current test item (including its child test items and further iterations) and will proceed with the next sibling test item.
Note: The total number of test item iterations is specified by the Count column of the Test Items page. - Project - If this value is selected and an error or an exception occurs during the test item run, TestComplete will stop the entire test project.
- None - If this value is selected, and an error or an exception occurs during the test item run, TestComplete proceeds with the project’s test items execution as if no error or exception occurred.
-
Some notes:
-
By default, the Stop on error and Stop on exception columns are hidden on the Test Items page. To make these columns visible, right-click within the Test Items page and select Field Chooser from the context menu. Then, drag the columns from the subsequent Customization dialog to the Test Items page.
-
Note that the parent item’s log includes the logs generated by child test items. So, if one of these child logs contains an error message, TestComplete will consider the parent log as containing an error message and will stop the test (or the parent test item).
-
The test item’s Stop on error property only has effect if the project’s Stop on error option is disabled.
The test item’s Stop on exception property only has effect if the project’s Error dialog option is disabled.
-
To obtain these property values from script, use the
TestItem.StopOnError
andTestItem.StopOnException
properties.
Stopping the Project Suite Test After the Project Test Fails
When TestComplete runs a project suite, it runs the projects that are selected for the run on the Test Items page of the project suite editor. If the project test is finished (or interrupted), the test engine starts searching for error messages in the project log. If errors are found, TestComplete will either stop the test run or continue with the next project depending on the Stop on Error value on the page:
To obtain this property value from script, you can use the StopOnError
property of the project suite’s test item.
Stopping the Test Item Right After an Error Occurs
If the project’s Stop on Error or Error dialog option is disabled, TestComplete does not stop the test run immediately when an error occurs. It continues the test run and checks the test log for the errors at the end of the test item or project run.
However, in some cases you may need to interrupt the current test item right after an error occurs. To do this, you create an OnLogError event handler. This event occurs every time TestComplete posts an error message to the log. The OnLogError
event handler will be called before the message is posted, so you can use it to check the error type and stop or continue the test run according to your needs. See other topics of this section for detailed information on various handling scenarios.
Stopping Distributed Testing When an Error Occurs
TestComplete distributed tests run test projects on several computers concurrently. By default, these test projects do not share information about errors during the run. That is, the master project receives information on errors that occur in slave projects only after the slave project run is over.
Also, if you run the distributed test as a project’s test item, the test engine will not recognize the failed slave project automatically and will continue the test run.
To stop the test item or other remote tests right after an error occurs you can use network variables and event handlers. For more information, see Stopping Tests on Hosts When an Error Occurs on One of Them.
See Also
Test Items Page (Project Editor)
Tests and Test Items
StopOnError Property
StopOnException Property
Running, Pausing and Stopping Automated Tests
Stopping Tests on Timeout