How to fail a test case in code?

Class library usage, coding and language questions.
mantov
Posts: 1
Joined: Mon Jul 20, 2015 10:07 am

How to fail a test case in code?

Post by mantov » Mon Jul 20, 2015 10:22 am

Hi i'm using Ranorex Studio. I have a test solution with a recording and user code file. The recording has a few steps(manual actions).

In my user code i set up a new thread, that periodically checks for any popups. If a popup appears, i want the test case to fail.

How do i fail the test case in code?

I tried :

Code: Select all

Validate.NotExists(repo.ScriptError.SelfInfo);
But that only throws an exception, it doesnt fail the test case.

I have also tried:

Code: Select all

Report.Failure("Validation", "my message");
Report.Log(ReportLevel.Failure, "failure message 2");
With the above code, the report logs these errors but the test case still passes.

Any help would be appreciated.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: How to fail a test case in code?

Post by odklizec » Mon Jul 20, 2015 12:20 pm

Hi,

If I'm not mistaken, there is still no way to pause/kill the test case (main thread) from popup watcher (second thread). Check for example the "workaround" post mentioned here:
http://www.ranorex.com/forum/popupwatch ... pup#p24914
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration