Ask a Question

Error in OnStartTest event stopping entire execution


Error in OnStartTest event stopping entire execution

Hello, I have recently started using the event handlers provided in TC, and I have been using them to make pre-validations and post-validations, but I have noticed that if there is any failure (Error) that come up while going through the steps inside these Event functions, then the entire test execution is stopped and the remaining tests on the list are not executed.


1. My test execution plan has 100 tests and I run them all together.

2. At the test case number 3, there is a failure in the OnStartTest event (e.g. TC tries to click an element that is not visible)

3. The test log report is displayed and all the remaining tests (from test #3 to test #100) appear as "Unexecuted".


Is this the expected behavior? Is there any way to avoid stopping the entire execution if anything fails inside the event handlers? 


Note: I have my Playback settings as "OnError: Stop current item and continue running" and "Rerun failed test item times =  2"

Regular Contributor

What is the OnError setting for your test items within the Test Execution plan set to? This may need to be set to Use project's 'on error' property or continue running or stop current item. And what are you doing inside of your OnStartTest event handler? Ideally you do not want your event handler to fail because TC cannot complete its handling of the error and thus does not know what to do next. By default these event handlers just post a message to the log, but if you're creating your own custom logic within that handler, then you may want to start by fixing that fail point first.




[[ kITt: keep IT testing ]]

Hello sir, if you had read my entire first post, your first question was answered at the end: "Note: I have my Playback settings as "OnError: Stop current item and continue running" and "Rerun failed test item times =  2"".

Then, my OnStartTest event makes several validations that I (as a user) would do whenever I work with my applications (in this case, the applications under test) at the moment I start my test case. An example could be "verify the app is opened and on the home page; if it's not opened, open it, and if it's not on the home page, go to the home page". Sometimes TC fails to open the app (the devs should know why, since what you get when that happens is a very generic message of "TC failed to open this app"), which causes the entire execution to break. 

Given the tool provides an event where the test starts, should anything unexpected happen on this event, it should not disrupt the execution of the following tests (since, after all, they will also trigger an OnStartTest event).

Maybe I should open a feature request so this gets fixed, because the way it works now, it's pretty useless unless you want to simply change an output message.


Regular Contributor

Hello sir, if you had read my entire first response and noticed the provided screenshots you might have noticed my reference to the settings in your Execution Plan and not the Playback settings of your Project that you keep referring to - because, depending on how you are running your tests, these settings could effect how TestComplete handles the error.


All settings aside, what you really need to debug is the OnStartTest event. If any event handler fails on the code that you wrote within it, then TC cannot gracefully follow through with is handling of the error, which can then effect the rest of the run. So using your example, if you do indeed have your own custom code in the event handler and it's going off to "verify the app is opened and on the home page" before it has actually attempted to launch you app, then yes, it will continue to fail and you need to refactor the code within the event handler. 


For additional context: Have you added this app in your project's Tested Apps config [TC reference]? Is this a desktop application or a web app that you are trying to find? Do you have the appropriate licensing? Can you open this application locally outside of TC? Even posting a snippet of the code within the event handler that is failing may help others with more appropriate suggestions.

[[ kITt: keep IT testing ]]
Showing results for 
Search instead for 
Did you mean: