Search code examples
mbunit

MbUnit - Getting test failure/success result in TestFixtureTearDown


I am using MbUnit for some integration tests. In the TestFixtureSetUp, I create a new instance of a database (using a GUID as the DB name). In the tear down, I delete it.

However, if tests fail, I want to keep the database alive (so I can investigate). Is there a way to tell from my TestFixtureTearDown whether the tests passed or failed?

In code it would look like:

[TestFixtureTearDown]
public void Stop()
{
    if (/* All tests passed */)
    {
       Database.Dispose();
    }
}

Solution

  • In MbUnit v3 you use: TestContext.Current.Outcome.Status == TestStatus.Passed

    Please note that in MbUnit v3 [TestFixtureSetUp] was renamed to [FixtureSetUp].