Page 1 of 1

PopupWatcher.Watch: How to set testcase to FAIL?

Posted: Tue Mar 25, 2014 5:42 pm
by bru
As PopupWatcher.WatchAndClick reports the occurence of a popup just as Info, I tried to call my own method using PopupWatcher.Watch:

Code: Select all

 myCrashWatcher.Watch(repo.dlg_ToolCrash.btn_ProgrammSchliessenInfo, myCrashWatcherFunc);

public static void myCrashWatcherFunc(Ranorex.Core.Repository.RepoItemInfo myInfo, Ranorex.Core.Element myElement)  
		{  
        	Report.Error ("myCrashWatcherFunc: program crashed!");
        	Report.Screenshot(myElement.Parent);
        	myElement.As<Ranorex.Button>().Click();
        }
This logs the popup as Error (Report Level = Error), but still the testcase in which this popup occured, will be reported as PASSED.

How can I set the testcase to FAIL?

Thanks,
Juergen

Re: PopupWatcher.Watch: How to set testcase to FAIL?

Posted: Tue Mar 25, 2014 6:31 pm
by odklizec
Hi,

Try Report.Failure instead of Report.Error.

Re: PopupWatcher.Watch: How to set testcase to FAIL?

Posted: Wed Mar 26, 2014 3:07 pm
by bru
Thanks a lot for your hint!

Best regards,
Juergen

Re: PopupWatcher.Watch: How to set testcase to FAIL?

Posted: Wed Mar 26, 2014 3:12 pm
by odklizec
You are welcome!

Re: PopupWatcher.Watch: How to set testcase to FAIL?

Posted: Thu Mar 27, 2014 9:35 am
by bru
Sorry, I have to come back again.
(As this is a sporadic issue, I could not test it immediately)

It will be reported as failure (Level = Failure) now, but still the Recording and the Testcase in which this Popup occurs will be shown as Passed.

Does anybody have further ideas?

Thanks,
Juergen

Re: PopupWatcher.Watch: How to set testcase to FAIL?

Posted: Thu Mar 27, 2014 10:45 am
by odklizec
Hi,

I think you are facing the same or similar problem as I did some time ago. The problem is that the popupwatcher runs in a separated thread. And as far as I know, there is currently no way to tell the main thread (from popupwacher thread) that the test case should be set as failed (eventually terminate the iteration/test case).

Please take a look at my post here:
http://www.ranorex.com/forum/command-to ... tml#p15846
Simply in the popup watcher, you need to set a variable, which needs to be evaluated somewhere in your test case/iteration (at start, at end, anywhere else?). Hope this helps? ;)

Re: PopupWatcher.Watch: How to set testcase to FAIL?

Posted: Mon Mar 31, 2014 4:54 pm
by bru
Thanks!

I've just tried your hint (static variable in class which will be set in popupwatcher method and will be evaluated at the end of the recording) and it works perfectly!

Thanks again!
Juergen

Re: PopupWatcher.Watch: How to set testcase to FAIL?

Posted: Mon Mar 31, 2014 5:37 pm
by odklizec
You are welcome! I'm glad I could help.