Using Assert.Inconclusive with Ranorex??

Ask general questions here.
brgibb
Posts: 39
Joined: Wed Jun 05, 2013 2:15 pm

Using Assert.Inconclusive with Ranorex??

Post by brgibb » Fri Feb 28, 2014 10:47 am

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.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Using Assert.Inconclusive with Ranorex??

Post by Support Team » Mon Mar 03, 2014 5:07 pm

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
.
Image

brgibb
Posts: 39
Joined: Wed Jun 05, 2013 2:15 pm

Re: Using Assert.Inconclusive with Ranorex??

Post by brgibb » Tue Mar 11, 2014 9:17 am

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?

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Using Assert.Inconclusive with Ranorex??

Post by Support Team » Thu Mar 13, 2014 5:24 pm

Hi brgibb,

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

Regards,
Bernhard
.
Image

brgibb
Posts: 39
Joined: Wed Jun 05, 2013 2:15 pm

Re: Using Assert.Inconclusive with Ranorex??

Post by brgibb » Fri Mar 14, 2014 9:44 am

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?

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Using Assert.Inconclusive with Ranorex??

Post by Support Team » Mon Mar 17, 2014 4:55 pm

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
.
Image

Mihaela
Posts: 2
Joined: Tue Feb 10, 2015 5:44 pm

Re: Using Assert.Inconclusive with Ranorex??

Post by Mihaela » Mon Mar 23, 2015 3:36 pm

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!");
}