Thanks for the answers Jeff, I'll explore these.

My use case is that we have developed a small suite of tests to verify
the functionality of the MbUnit tests we are using. Basically
verification tests to show that MbUnit will pass when appropriate and
will fail when appropriate. To simplify a testers life we want to take
all tests that fail, like:


        [Test]
        [ExpectedException(typeof (Exception))]
        public void WillFailIfNoExceptionIsThrown()
        {

        }

And 'catch' the failure. This allows the test to actually pass, and
the test report itself will show 100% success. Currently anyone
looking at this report will see a mix of passes and failures. All the
failures are deliberate, but its cumbersome to verify each. The
thought is that if we have everything passing it will simplify the
verification process.

So as of right now all the tests pass except a few involving
ExpectedException and a Contract Verifiers. All others tests that
originally fail do a try/catch and catch the
AssertionFailureException. The Failure.Description property of the
exception is compared (via Assert.AreEqual) with a string of the
expected message.

On Apr 29, 1:02 pm, Jeff Brown <[email protected]> wrote:
> I am curious what your usecase is.
> However you can determine whether a test failed by looking at the  
> TestContext.Current.TestOutcome property in TearDown.
>
> Another solution is to create a custom decorator attribute by  
> subclassing TestDecoratorAttribute and overriding Execute.
>
> Jeff
>
> On Apr 29, 2009, at 9:30 AM, Jason <[email protected]> wrote:
>
>
>
> > I am looking for a way to catch the failure on a test with an
> > ExpectedException attribute. Basically if the expected exception isn't
> > thrown I want to be notified before the test is marked as a failure.
> > On tests that use an Assert and fail, I can catch the
> > AssertionFailureException. Is there a way to do this with
> > ExpectedException tests? Thanks!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"MbUnit.User" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/MbUnitUser?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to