以编程方式从NUnit检索结果 [英] Retrieve Results from NUnit Programmatically

查看:76
本文介绍了以编程方式从NUnit检索结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以检索以编程方式使用NUnit运行的单元测试的结果?如果是,那么如何?我已经读过我们可以使用Nunit Console生成XML文件.除了生成然后解析XML之外,还有其他方法吗?

Is it possible to retrieve the results of the Unit tests run using NUnit programmatically? If Yes then How? I have read that we can generate XML file using Nunit Console. Is there any other way around apart from generating and then parsing XML?

推荐答案

是的,有可能.您可以使用当前的测试上下文获取测试名称,状态,工作目录等

Yes, it is possible. You can use current test context to get name of test, status, working directory, etc

[TearDown]
public void TearDown()
{
    var context = TestContext.CurrentContext;
    // context.Test.Name
    // context.Result.Status
}

这篇关于以编程方式从NUnit检索结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆