NUnit的:访问失败消息在TearDown中() [英] NUnit: Accessing the Failure Message in TearDown()

查看:156
本文介绍了NUnit的:访问失败消息在TearDown中()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图登录的自动化测试的结果NUnit的一个小数据库上运行,这样的数据是方便和更安全地记录各种原因。 (有一个关于〜550自动化测试和运行它们都可能需要数天)

I'm trying to log the results of automated tests run in NUnit in a small database so that data is easily accessible and more securely logged for various reasons. (There's about ~550 automated tests and running them all can take days)

我已经有机会获得测试的结束状态(合格/不合格/错误/取消/跳过等),但我想记录额外的细节。

I already have access to the ending status of the test (Passed/Failed/Error/Cancelled/Skipped etc..) but I'd like to log the extra detail.

我期待在TearDown中()做到这一点。

I am looking to do this within TearDown().

这是我能找到的最接近,但没有提供给我一个答案:
https://groups.google.com/forum/?fromgroups=#!msg/nunit-discuss/lXxwECvpqFc/IbKOfQlbJe8J

This is the closest thing I could find, but did not provide me with an answer: https://groups.google.com/forum/?fromgroups=#!msg/nunit-discuss/lXxwECvpqFc/IbKOfQlbJe8J

想法?

推荐答案

我相信你能得到你的 NUnit的事件监听器的。我还没有使用这些我自己,但我已经拥有他们喜爱的做类似你要完成的事情。

I believe you'll be able to get the information you need with NUnit EventListeners. I haven't used these myself, but I've had them bookmarked to do something similar to what you're trying to accomplish.

下面是你要使用的接口。希望您的 TearDown中方法将被调用之前 TestFinished 而已,但我无法验证这一点。

Here's the interface you'd be working with. Hopefully your TearDown method would be called just before TestFinished, but I can't verify this.

public interface EventListener
{
    void RunStarted(string name, int testCount );
    void RunFinished(TestResult result);
    void RunFinished(Exception exception);
    void TestStarted(TestName testName);
    void TestFinished(TestResult result);
    void SuiteStarted(TestName testName);
    void SuiteFinished(TestResult result);
    void UnhandledException(Exception exception);
    void TestOutput(TestOutput testOutput);
}

这篇关于NUnit的:访问失败消息在TearDown中()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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