Page 1 of 1

Using Assert.Inconclusive with Ranorex??

Posted: Fri Feb 28, 2014 10:47 am
by brgibb
I'm just wondering how under certain conditions I can handle Ranorex exceptions in different ways depending on the scenario.

For example....

It actually might be ok that a certain element was not found and in this case I want to flag up a warning rather than fail the test.

My tests are executed via nunit and I was wondering about using Assert.Inconclusive or Assert.Ignore in the exception handler.

However in other cases I would want the case to fail so I would need a different handler.

Apologies my exception handling knowledge is novice at best.

Is there a better way to to this.... I'm guessing there might be.

Re: Using Assert.Inconclusive with Ranorex??

Posted: Mon Mar 03, 2014 5:07 pm
by Support Team
Hi brgibb,

You can try to embed the specific line of code into a "try catch" block.
try {
	repo.YourItem.Self.Click();
	Delay.Milliseconds(200);
} catch(Exception ex) {
	Report.Log(ReportLevel.Warn, "Could not click item!");
}
Regards,
Bernhard

Re: Using Assert.Inconclusive with Ranorex??

Posted: Tue Mar 11, 2014 9:17 am
by brgibb
Thanks for your reply.

this would throw a Ranorex warning but can you help me further....how would I then pass this back to a nUnit test so that the nUnit console shows the test in yellow rather than green or red?

Re: Using Assert.Inconclusive with Ranorex??

Posted: Thu Mar 13, 2014 5:24 pm
by Support Team
Hi brgibb,

Unfortunately I am not exactly sure what you mean. Can you please describe the issue in more detail?

Regards,
Bernhard

Re: Using Assert.Inconclusive with Ranorex??

Posted: Fri Mar 14, 2014 9:44 am
by brgibb
Hi,

Essentially how do I get get nUnit to report an inconclusive result (i.e. yellow) rather than a pass or a fail when Ranorex throws a report.info "warning".

All of my Ranorex functionality is called from an nUnit test with a try / catch round the call and I would like the nUnit results to show that there has been a warning found ...not just Ranorex.

If I understood you first reply correctly you were suggesting I put a try / catch round the attempt to find an element.This is fine as Ranorex will report a warning in the Ranorex report via the catch but it would not pass this warning result back to the calling nUnit test.....it presumably would simply pass would it not?

Does this make sense?

Re: Using Assert.Inconclusive with Ranorex??

Posted: Mon Mar 17, 2014 4:55 pm
by Support Team
Hello brgibb,

As I know it should work using the "Console.Error.Write()" method.
Console.Error.Write("Your message", ConsoleColor.Yellow);
I am afraid that I cannot provide deeper support concerning this problem because this is not an issue in Ranorex. Maybe other users in our forum have more experience with NUnit and can give you more information about that.

Regards,
Bernhard

Re: Using Assert.Inconclusive with Ranorex??

Posted: Mon Mar 23, 2015 3:36 pm
by Mihaela
Hi brgibb,
in the example Bernard provided,in the catch under Report.Log, you can add Assert.Ignore("Your warning message here"). That will mark the nunit test in yellow
Support Team wrote:
try {
	repo.YourItem.Self.Click();
	Delay.Milliseconds(200);
} catch(Exception ex) {
	Report.Log(ReportLevel.Warn, "Could not click item!");
}