Page 1 of 1

NUnit + Exception

Posted: Wed May 19, 2010 6:29 am
by SanMan
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?

Re: NUnit + Exception

Posted: Wed May 19, 2010 8:41 am
by Support Team
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