Mark Test as Error from End Activity Event Code

Ask general questions here.
semate
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
Error occurs at PLY_Observertest Recording.

Thanks for your help!
You do not have the required permissions to view the files attached to this post.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
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

Hi,

Try to use this:

Code: Select all

throw new Exception(message);
Eventually check the approach described here:
https://www.ranorex.com/forum/how-to-fa ... 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