Is there a test status property in NUnit 3.0?

In NUnit v. <3.0 there was a TestContext class, and there was a property that could tell us about the status of a previously executed test.

To access the property, we can use TestContext.CurrentContext.Result.Status

Now in NUnit 3.0 there is no property like Status ! Therefore, all my tests need to be changed.

My question is this: is it possible to get test status in NUnit 3.0, as was possible in the previous version?

An interesting thing : there was a TestStatus class with properties: Passed, Failed , etc., and we used it to compare with the current status. This class is present in NUnit 3.0!

My code is:

 if (TestContext.CurrentContext.Result.Status == TestStatus.Failed) { //Be happy if it works) } 
+5
source share
1 answer

I searched deeper and found a solution!

Now in NUnit 3.0 we have to change this:

 TestContext.CurrentContext.Result.Status 

For this:

 TestContext.CurrentContext.Result.Outcome.Status 
+8
source

Source: https://habr.com/ru/post/1236065/


All Articles