nunit: Warning in TearDown is inconsistent with Assertion failure

When an Assertion is used in TearDown and fails, an error is generated. That is, the result is Failed:Error rather than simply Failed. Similarly, failure of an Assumption generates an error.

NUnit has worked this way historically because it is generally necessary for the TearDown method to complete, in order to clean things up.

As we implemented Warnings, a Warning failure in TearDown works differently from Assertion failure. The assertion is counted and a Warning level AssertionResult is created, but it has no effect on the overall result of the test. If there are no other warnings or failures, the test passes.

Alternatives:

  1. Document that Warnings in TearDown have no effect on the result of the test although they may be reported by some runners. This seems confusing to me. If we are going to report it, then the test should have an overall warning result.

  2. Handle Warnings in TearDown by changing the result to Warning if the test passed. This sounds like it could be useful but is still inconsistent with failing Assertions.

  3. Generate an error for failed warnings in TearDown just as we do for assertion failures.

A Warning in TearDown generally gives seems to be ignored entirely

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 17 (17 by maintainers)

Most upvoted comments

Sounds like 3 of us prefer option 2 then.