title: NUnit - cleanup after test failure
body: <p>We have some NUnit tests that access the database. When one of them fails it can leave database in inconsistent state - which is not an issue, since we rebuild database for every test run - but it can cause other tests to fail in the same run.</p>
  
  <p>Is it possible to detect that one of the tests failed and perform some sort of cleanup?</p>
  
  <p>We don't want to write cleanup code in every test, we already do that now. I'd like to perfrom cleanup in Teardown but only if test failed, as cleanup might be expensive.</p>
  
  <p><strong>Update</strong>: To clarify - I would like tests to be simple and NOT include any cleanup or error handling logic. I also don't want to perform database reset on every test run - only if test fails. And this code should probably be executed in Teardown method but I am not aware of any way to get info if test we are currently tearing down from failed or was successful.</p>
  
  <p><strong>Update2</strong>:</p>
  
  <pre><code>        [Test]
          public void MyFailTest()
          {
              throw new InvalidOperationException();
          }
  
          [Test]
          public void MySuccessTest()
          {
              Assert.That(true, Is.True);
          }
  
          [TearDown]
          public void CleanUpOnError()
          {
              if (HasLastTestFailed()) CleanUpDatabase();
          }
  </code></pre>
  
  <p>I am looking for implementation of HasLastTestFailed()</p>