Exit current test case?

Ask general questions here.
MJesper
Posts: 38
Joined: Fri Dec 28, 2018 2:16 pm

Exit current test case?

Post by MJesper » Wed Jan 23, 2019 1:53 pm

Is there a way to exit the current running test case? From my googling I've only found outdated results.

What I want to do:
If the program gets an error I want the entire test to stop and report the error.

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

Re: Exit current test case?

Post by odklizec » Wed Jan 23, 2019 1:59 pm

Hi,

Could you please be a bit more specific what exactly you want to achieve? Basically, you can throw a Ranorex exception anywhere in the test case, eventually use Validate.Fail method. Additionally, you should set correct Error Behavior for given TestCase and/or parent SmartFolder/TestSuite.

I see you updated your post with more details. To stop the entire test, you must set correct Error Behavior (Stop) for parent container(s).
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

MJesper
Posts: 38
Joined: Fri Dec 28, 2018 2:16 pm

Re: Exit current test case?

Post by MJesper » Wed Jan 23, 2019 2:07 pm

This did not work /: Even if I throw an exception and do Report.Error it keeps on going.

Might be worth noting that this is happening inside the WatchPopup thread?

Code: Select all

Report.Error(message);
throw new Exception(message);

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

Re: Exit current test case?

Post by odklizec » Wed Jan 23, 2019 2:26 pm

Hi,

I'm afraid, you can't directly stop the test case from popupwatcher. This is something we discussed a while ago. Since then, Ranorex implemented PauseWhileExists popupwatcher method (in Ranorex automation helpers), which allows to pause the main thread from popup watcher. See this post:
stop-current-tc-and-run-next-t12316.html#p49460
But there is still no a publicly available way to stop the test case (in main thread). What you can try is to use this little trick, which may help:
how-to-failing-a-test-case-in-popup-wat ... tml#p46702
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

MJesper
Posts: 38
Joined: Fri Dec 28, 2018 2:16 pm

Re: Exit current test case?

Post by MJesper » Wed Jan 23, 2019 2:29 pm

Ah so I have to use Environment.Exit then. Hopefully they'll add some fix to this. Thanks anyways :D