How to fail a test case in code?

Class library usage, coding and language questions.
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

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
Ranorex Guru
Ranorex Guru
Posts: 6529
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


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: ... 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