NUnit + Exception

Ask general questions here.
SanMan
Posts: 210
Joined: Tue Apr 13, 2010 9:59 am

NUnit + Exception

Post by SanMan » Wed May 19, 2010 6:29 am

Hi,

When I am running testcases via NUnit, where should I add the
try{}
catch{Exception e}
Report.Screenshot();

so that I will receive the screenshot if something goes wrong in my testcase?

If I add it to this [test], NUnit will pass the test in case of failure.

p.s. Does anyone here know, how to use NUnit2Report to make readable reports from NUnit genereded Testresults.xml?

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: NUnit + Exception

Post by Support Team » Wed May 19, 2010 8:41 am

Hi!
SanMan wrote:so that I will receive the screenshot if something goes wrong in my testcase?
Just add a try-catch block over the code that can throw an exception (like you would do it in a normal Ranorex Console Application) and re-throw the exception at the end of the catch.
catch (YourException e)
{
  Report.Error(e.ToString());
  Report.Screenshot();
  error = -1;
  throw;
}
SanMan wrote:Does anyone here know, how to use NUnit2Report to make readable reports from NUnit genereded Testresults.xml?
Sorry we don't have experience with NUnit2Report.

Regards,
Peter
Ranorex Support Team