Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there test status property in NUnit 3.0?

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)
}
like image 387
Denis Koreyba Avatar asked Nov 16 '15 16:11

Denis Koreyba


1 Answers

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
like image 83
Denis Koreyba Avatar answered Nov 07 '22 21:11

Denis Koreyba