← Back to team overview

nunit-core team mailing list archive

[Bug 691455] Re: Overriding test result in TearDown

 

Spoke a little too soon. Asserting in the TearDown method is less than
ideal. The assert will append its failure message to whatever
errors/asserts were encountered in the SetUp or Test method when what I
really want to do is replace the failure message entirely.

-- 
You received this bug notification because you are a member of NUnit
Developers, which is subscribed to NUnit V2.
https://bugs.launchpad.net/bugs/691455

Title:
  Overriding test result in TearDown

Status in NUnit V2 Test Framework:
  Incomplete

Bug description:
  NUnit version 2.5.7
  Runner: Console and GUI

  Feature Request:

  I'd love to have the ability to override a test's result (e.g.
  Pass/Fail/Error) in the [TearDown] method along with the option to
  overwrite the error message.

  Some more background:

  I just started with a team that uses NUnit for running for automation
  testing. Given that NUnit is specifically built for unit testing, I've
  been surprised just how well it meets our needs. The only hangup I
  currently have is that we have certain classes of errors that only
  occur on threads other than the main thread. Without going into
  details, it's basically impossible for us respond to these errors on
  the main thread without adding code everywhere to poll if any of these
  errors have occurred, and if so, Assert.Fail(). Without detecting the
  errors at all, our code ends up asserting or throwing an exception for
  something else on the main thread which just ends up obfuscating the
  real problem in the resulting TestResult.xml file.

  I understand why NUnit doesn't pick up assertions/exceptions on
  different threads, but we could easily workaround this if we had the
  ability to override the test result and error message in the
  [TearDown] method. At that point we'd know if any of these errors had
  occurred and could signal the test as failing and give a more
  appropriate message.



References