Forum Discussion
- Setup and Tear Down - Yes there are on test start and on test stop even handlers. https://support.smartbear.com/testcomplete/docs/testing-with/advanced/handling-events/creating-handlers/index.html?q=event+handlers
- In your project properties, do you have stop on error checked? If so that will cause the test to stop on any error.
Thank you for your suggestion for event handlers. Those are exactly what I was looking for.
I do have a follow up question about try/catch errors. I basically want to shut down my application before I try to open it. So, what I planned on doing is in a try block, put in the function to shut down my application, and not really do much in catch. Doing it this way, even with that option unchecked, this behavior will make it look like all my tests fail, when it only failed expectedly when it could not find my open application. I just thought try catch blocks did not report a test had failed, unless you threw your own error in the catch block. Is there a better way to check processes or something to verify if my application is running before trying to close it? I just thought the try catch was a pretty easy way to do this, until it actually reported successful tests were failures.
- cunderw8 years agoCommunity Hero
So the try / catches will only catch code errors and exceptions, not Test Complete errors.
Test complete is logging an error when you are getting when you try to close your application if it's not open because there is no object to send the terminate command too. It's not throwing an exception which is why the try / catch is not catching it.
There are several ways to go about it (depends on if you're mapping, using finds, etc..). But, in general what you would want to do is check if you application is running and only force the shut down if it is.
Some psuedo code:
if(Aliases.application.Exists) { Aliases.application.Terminate() } else { Log.Message("Application Not Running") }
- AlexKaras8 years agoChampion Level 3
> check if you application is running
> if(Aliases.application.Exists)
The better approach is to use one of the WaitXXX() methods provided by TestComplete. I.e.:
if(Aliases.WaitAliasChild("application", 500).Exists)
The reason for that is that the original line of code will post an error to the log if application is not running, while modified line will not.
- cunderw8 years agoCommunity Hero
As long as you check for Exists is on the very top most node of the application, you will not get an error, just Exists = false.
Related Content
- 2 years ago
- 2 years ago
- 6 months ago
Recent Discussions
- 30 minutes ago
- 24 hours ago
- 7 days ago
- 11 days ago