gpt4 book ai didi

c# - NUnit:访问 TearDown() 中的失败消息

转载 作者:行者123 更新时间:2023-11-30 14:34:15 26 4
gpt4 key购买 nike

我正在尝试将在 NUnit 中运行的自动化测试的结果记录在一个小型数据库中,以便出于各种原因可以轻松访问数据并更安全地记录数据。 (大约有 ~550 个自动化测试,运行它们可能需要几天时间)

我已经可以访问测试的结束状态(通过/失败/错误/取消/跳过等),但我想记录额外的详细信息。

我希望在 TearDown() 中执行此操作。

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

想法?

最佳答案

我相信您可以使用 NUnit EventListeners 获得所需的信息.我自己没有使用过这些,但我已将它们加入书签以执行类似于您要完成的操作。

这是您将要使用的界面。希望您的 TearDown 方法会在 TestFinished 之前被调用,但我无法验证这一点。

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);
}

关于c# - NUnit:访问 TearDown() 中的失败消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14340934/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com