gpt4 book ai didi

c# - NUnit TestContext.CurrentContext 空引用异常

转载 作者:太空狗 更新时间:2023-10-30 00:57:23 24 4
gpt4 key购买 nike

我今天早上一直在玩 watiN/Nunit 以捕获失败的 UI 测试的屏幕截图。但是,我在访问 Nunits TestContext.CurrentContext 时遇到了 NRE...

关于我做错了什么有什么想法吗?

[TestFixture]
class SomePageTest
{
[Test]
[STAThread]
public void Page_IsAvailable()
{
var browser = new SomePage();

Assert.IsTrue(browser.ContainsText("Something"));

if (TestContext.CurrentContext.Result.Status == TestStatus.Failed)
{
browser.CaptureWebPageToFile(@"X:\location\" + TestContext.CurrentContext.Test.FullName);
}
}
}

public class SomePage: IE
{
public static string SomePageUrl = "http://somepage.com/someurl";
public SomePage() : base(SomePageUrl)
{
}
}

最佳答案

好吧......在深入研究这个异常没有成功之后,我看到了这篇文章:http://www.barebonescoder.com/2010/10/nunit-and-the-new-testcontext-class/

从 nunit 的测试运行器运行我的测试是成功的...现在要弄清楚如何使用 resharpers 测试运行器来完成这项工作?

关于c# - NUnit TestContext.CurrentContext 空引用异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5363635/

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