Re: Expected Unhandled Exceptions
Wade Barnes <[email protected]> Fri, 11 Jul 2008 12:27:21 -0700
| Newsgroups | gmane.comp.windows.dotnet.nunit.user |
|---|---|
| Message-ID | <[email protected]> |
Hi Rocco, Unfortunatly the ExpectedExceptionAttribute method does not seem to be able detect and associate a truly unhandled exception from one AppDomain to a given test running in a different AppDomain; unless I am missing something. The ExpectedExceptionAttribute works great in situaltions where you could also use a try, catch; I've been using it for years. In my situaltion the only way you can detect the exception is through the AppDomain's UnhandledException event. The exception is originating inside a child AppDomain on a thread that is isolated inside that AppDomain. Therefore the unhandled exception is only reported in that AppDomain and to any subscribers to its UnhandledException event; hence how nunit detects the exception. Thanks anyway, Wade ----- Original Message ----- From: "Pigneri, Rocco" <[email protected]> Date: Friday, July 11, 2008 11:50 am Subject: RE: [Nunit-users] Expected Unhandled Exceptions To: Wade Barnes <[email protected]>, [email protected] > Dear Wade, > > > > Try the ExpectedException attribute, documented here: > > > > http://www.nunit.org/index.php?p=exception&r=2.4.7 > > > > I would recommend > > > > [ExpectedException("System.Exception")] > > > > since it sounds like you just want to ensure that *any* > exception was > thrown. > > > > Hope that helps, > > > > Rocco > > > > From: [email protected] > [mailto:[email protected]] On Behalf Of Wade > Barnes > Sent: Friday, July 11, 2008 12:20 PM > To: [email protected] > Subject: [Nunit-users] Expected Unhandled Exceptions > > > > Hi, > > Is there any way to tell a particular test to expect an unhandled > exception; one that would normally be indicated through the > AppDomain.UnhandledException event? > > > > I am testing code that uses AppDomains to isolate code. > One of the > tests purposely causes an unhandled exception in one of these > AppDomainsto ensure it is properly reported and acted upon by > the code managing > the AppDomains; therefore I am expecting an unhandled exception to > occur. > > The issue: > > The test itself passes. > > However, > > When using the GUI runner the test bar goes Red and the unhandled > exception is reported in the output list. > > When using the Console runner this same unhandled exception > causes the > runner to return a code of -100; this ends up failing our > nightly build. > > > > What I would like to do: > > I would like to be able to indicate, for a particular test, that an > unhandled exception is expected. I would then expect the > test to behave > similarly to any other test expecting an exception; if received > it happy > goes about the remained of its testing business, otherwise it fails > because it did not receive the expected exception. > Additionally when > such a test is encountered I would expect the test bar in the > GUI not to > turn Red and the unhandled exception not to be reported in the output > list; similarly I would expect the Console runner not to return -100. > > > > Wade > > ------------------------------------------------------------------------- Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! Studies have shown that voting for your favorite open source project, along with a healthy diet, reduces your potential for chronic lameness and boredom. Vote Now at http://www.sourceforge.net/community/cca08 _______________________________________________ Nunit-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/nunit-users