Page 1 of 1

Mark Test as Error from End Activity Event Code

Posted: Thu Feb 06, 2020 2:16 pm
by semate
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!

Re: Mark Test as Error from End Activity Event Code

Posted: Thu Feb 06, 2020 2:39 pm
by odklizec
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