Re: Expected Unhandled Exceptions

"Pigneri, Rocco" <[email protected]> Fri, 11 Jul 2008 14:52:39 -0400
Newsgroups gmane.comp.windows.dotnet.nunit.user
Message-ID <D04B62A56C65EA4B860036108BD0A66C02638A4B@boston-ex.lavastorm.local.com>
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 AppDomains
to 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