I am converting the following code from MSTest V2 to NUnit 3. Can you help me find the alternatives of CurrentTestOutcome and UnitTestOutcome in NUnit?
var status = MyTestContext.CurrentTestOutcome;
switch (status)
{
case UnitTestOutcome.Failed:
TheLogger.Error($"Test Failed => {MyTestContext.FullyQualifiedTestClassName}");
CurrentTestCase.AddScreenCaptureFromPath(screenshotPath);
CurrentTestCase.Fail("Fail");
break;
case UnitTestOutcome.Inconclusive:
CurrentTestCase.AddScreenCaptureFromPath(screenshotPath);
CurrentTestCase.Warning("Inconclusive");
break;
case UnitTestOutcome.Unknown:
CurrentTestCase.Skip("Test skipped");
break;
default:
CurrentTestCase.Pass("Pass");
break;
}
I am switching based on current test case outcome. I have found that MyTestContext.Result.Outcome is alternative for MyTestContext.CurrentTestOutcome in NUnit but what will be the alternative for UnitTestOutcome.Inconclusive etc in NUnit? thanks
You have TestStatus
in TestContext
var status = TestContext.CurrentContext.Result.Outcome.Status;
switch (status)
{
case TestStatus.Inconclusive:
break;
case TestStatus.Skipped:
break;
case TestStatus.Passed:
break;
case TestStatus.Failed:
break;
case TestStatus.Warning:
break;
}