Mark Test as Error from End Activity Event Code

Ask general questions here.
Posts: 19
Joined: Tue Jul 03, 2018 7:42 am

Mark Test as Error from End Activity Event Code

Post by semate » Thu Feb 06, 2020 2:16 pm

Hi everybody!

The developer made a label appear if an unknow error gets caught.
I need to check for this label best after every action and then copy the log of the Windows Application and other stuff.

So I decided to go with the Event Handler for End Activity. Works well except the fact, that I can't mark the test case properly as failure.

Code: Select all

ActivityStack.Instance.EndActivity += new EventHandler(ActivityStack_Instance_EndActivity);
static void ActivityStack_Instance_EndActivity(object sender, EventArgs e)
	if (error_condition)
		Report.Failure("ERROR", "Severe Error active");	// prints but does not mark test/testrun as failed 
	 	Validate.Fail("SevereError");		// causes the red X behind the test, but does not mark the test/testrun as failed
ErrorInEvent.PNG (7.63 KiB) Viewed 295 times
Error occurs at PLY_Observertest Recording.

Thanks for your help!

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

Re: Mark Test as Error from End Activity Event Code

Post by odklizec » Thu Feb 06, 2020 2:39 pm


Try to use this:

Code: Select all

throw new Exception(message);
Eventually check the approach described here: ... 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