MbUnit - Getting test failure/success result in TestFixtureTearDown
-
20-08-2019 - |
Question
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].
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow