将 MSTest 转换为 NUnit:NUnit 中的 CurrentTestOutcome 和 UnitTestOutcome 替代方案
Converting MSTest to NUnit: CurrentTestOutcome and UnitTestOutcome alternatives in NUnit
我正在将以下代码从 MSTest V2 转换为 NUnit 3。你能帮我找到 CurrentTestOutcome 和 UnitTestOutcome 在 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;
}
我正在根据当前测试用例结果进行切换。我发现 MyTestContext.Result.Outcome 是 NUnit 中 MyTestContext.CurrentTestOutcome 的替代品,但是 NUnit 中 UnitTestOutcome.Inconclusive 等的替代品是什么?谢谢
您在 TestContext
中有 TestStatus
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;
}
我正在将以下代码从 MSTest V2 转换为 NUnit 3。你能帮我找到 CurrentTestOutcome 和 UnitTestOutcome 在 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;
}
我正在根据当前测试用例结果进行切换。我发现 MyTestContext.Result.Outcome 是 NUnit 中 MyTestContext.CurrentTestOutcome 的替代品,但是 NUnit 中 UnitTestOutcome.Inconclusive 等的替代品是什么?谢谢
您在 TestContext
TestStatus
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;
}