In NUnit v. < 3.0 there was TestContext class and there was a property that could tell us a status of the previously run test.
To access the property we could use TestContext.CurrentContext.Result.Status
Now in NUnit 3.0 there is no property as Status! So all my tests need to be changed.
My question is the next: is it possible to get test status in NUnit 3.0 as it was possible to do in previous version?
Interesting thing: there was class TestStatus with properties: Passed, Failed etc. and we used it to compare with current status. This class is present in NUnit 3.0!
My code:
if (TestContext.CurrentContext.Result.Status == TestStatus.Failed)
{
//Be happy if it works)
}
I searched deeper and found the solution!
Now in NUnit 3.0 we have to change this:
TestContext.CurrentContext.Result.Status
To this:
TestContext.CurrentContext.Result.Outcome.Status
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With