NUnit - Is it possible to check in the TearDown whether the test succeeded?

Viewed 7827

I would like to have my TearDown method check whether the previous test was a success before it applies some logic. Is there an easy way to do this?

6 Answers
    [OneTimeTearDown]
    public void AfterEachTest()
    {
        if (TestContext.CurrentContext.Result.Outcome.Status.Equals(TestStatus.Failed))
        {
           Console.WriteLine("FAILS");

        }
        else if (TestContext.CurrentContext.Result.Outcome.Equals(ResultState.Success))
        {
            Console.WriteLine("SUCESS");

        }
    }
Related