2
在NUnit中,我可以从context.Result.State
得到测试结果。如果它的NUnit.Framework.TestState.Success
,那么我知道测试通过。如何从MSTest获取测试结果状态?
在MSTest中,我如何获取该信息?
我看到context.Properties.Keys
,但他们都没有提到测试结果的状态。
在NUnit中,我可以从context.Result.State
得到测试结果。如果它的NUnit.Framework.TestState.Success
,那么我知道测试通过。如何从MSTest获取测试结果状态?
在MSTest中,我如何获取该信息?
我看到context.Properties.Keys
,但他们都没有提到测试结果的状态。
使用TestContext.CurrentTestOutcome财产在TestCleanup
方法:
[TestClass]
public class UnitTest
{
private TestContext TestContext { get; set; }
[TestCleanup]
public void TestCleanup()
{
if (TestContext.CurrentTestOutcome == UnitTestOutcome.Passed)
//do something
}
[TestMethod]
public void TestMethod()
{
}
}
你能告诉我怎样才能得到实际的理由/日志(指为什么我的测试案例失败,上线数)在TestCleanup方法? – joinsaad