Add callback support to Asserts

Bug #1178412 reported by Christian Ang
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
NUnit Framework
New
Undecided
Unassigned

Bug Description

This feature is to allow you to add a callback method when you assert, that would run right before the test fails. This would allow you to perform your own logging when an assert fails, clean up anything the test did (such as a database connection), etc.

Revision history for this message
Charlie Poole (charlie.poole) wrote : Re: [Bug 1178412] [NEW] Add callback support to Asserts

This sounds like what Teardown does except that it's limited to a
particular Assert. Could also be implemented using an ActionAttribute.

Charlie
On May 9, 2013 9:30 PM, "Christian Ang" <email address hidden> wrote:

> Public bug reported:
>
> This feature is to allow you to add a callback method when you assert,
> that would run right before the test fails. This would allow you to
> perform your own logging when an assert fails, clean up anything the
> test did (such as a database connection), etc.
>
> ** Affects: nunitv2
> Importance: Undecided
> Status: New
>
> --
> You received this bug notification because you are subscribed to NUnit
> Extended Testing Platform.
> https://bugs.launchpad.net/bugs/1178412
>
> Title:
> Add callback support to Asserts
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/nunitv2/+bug/1178412/+subscriptions
>

Revision history for this message
Christian Ang (cang) wrote :

Now that I think about it the clean up was a bad example of a use case for a callback on an assert considering you could clean up on an tear down or with the action attribute. However, the case I ran into recently was I needed to log when an assert failed using our frameworks logger.

Now without a callback on an assert the only way I could perform work when a specific assert failed was to use a try/catch where I was able to try the assert, do my logging in the catch if it failed, and throw it back afterwards.

I think it would be much nicer to allow the user to specify a callback instead of performing a try/catch so it can still be a nice one liner and keep the test case clean.

affects: nunitv2 → nunit-3.0
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.