Page 2 of 2

Re: How to Handle Unhandled exception

Posted: Mon Jan 08, 2018 7:56 pm
by krstcs
If that is the case, then you should not be using the popup watcher at all. If you want the test to fail when that specific unhandled exception happens, then don't handle it and if your System Under Tests (SUT) can't continue then Ranorex will fail because it won't be able to continue executing the test with the exception in place.

The popup watcher should only be used to handle popups where the system/test should not fail, but needs to handle the popup in some way to allow the test to continue WITHOUT failure. The popup watcher is not designed for effective use as a test error handler.

If your test should fail due to a popup, then you should code the test so that it can't continue if the popup is there, using a Validate.NotExists(<Popup>) or something similar, or just letting Ranorex fail when trying to find/act on the next element.

In addition, the popup watcher runs in a separate thread than the test itself, and therefore will not be able to stop the test on a failure. The best you can do is create your callback method in such a way that it passes failure to the report via a Report.Failure() call. You will need to code your own callback for this though.

Re: How to Handle Unhandled exception

Posted: Mon Jan 08, 2018 8:06 pm
by armstronghm24
I am not sure I agree with the first part. It seems like the popup watcher was built for failures since they are for unexpected popups or am I not understanding something correctly? The reason I want to use the popup watcher is so that testing will continue if an unexpected popup error occurs, however I want to make sure the report still captures the failure. At least in my case, unexpected popups prevent any further testing since the normally functioning parts of the UI are disabled unless the popup is dismissed.

Re: How to Handle Unhandled exception

Posted: Mon Jan 08, 2018 9:02 pm
by odklizec
There is already a user voice regarding the ability to pause/stop main test thread from popupwatcher thread:
https://uservoice.ranorex.com/forums/15 ... from-popup
You can vote for it, but it already appears to be under review.

BTW check this post about killing test from popup watcher:
https://www.ranorex.com/forum/how-to-fa ... tml#p46702

Re: How to Handle Unhandled exception

Posted: Mon Jan 08, 2018 9:41 pm
by krstcs
As I said, if you want the test to fail, then you should code the test specifically for that. The popup watcher is there to handle things that should not normally impact (read fail) the test.

Once you have a failure in a test, you can really no longer trust the rest of the test. There is no way you can handle every possible situation that can result due to the failure, especially if it is an exception in the SUT.

You do whatever you think is right, but for me, a failure should stop the test. This is one reason that tests should be short and to-the-point. That way a failure only impacts that test and not others. However, in very complex SUTs that may not be possible. My question is, how do your users react to these failures? Do they have to start over? Is the system still stable, etc.? Just some things to think about.

Good luck!

Re: How to Handle Unhandled exception

Posted: Tue Jan 09, 2018 2:46 pm
by Vaughan.Douglas
I think the main reason you'd want to use this approach was to make sure you captured the exception details and allow for a clean exit from the test. If you don't handle it in this way, Ranorex will probably fail on some element error (not found, can't click, whatever) which doesn't tell you much about what really caused the exception. The popup watcher should trigger closer to the error event making it easier to backtrack.