NUnit TestContext.CurrentContext null 引用异常 [英] NUnit TestContext.CurrentContext null reference exception
问题描述
今天早上我一直在玩 watiN/Nunit 来捕获失败的 UI 测试的屏幕截图.但是,我在访问 Nunits TestContext.CurrentContext 时遇到了 NRE...
I've been playing around this morning with watiN / Nunit to capture a screenshot on failed UI tests. However, I'm running into NRE's when accessing Nunits TestContext.CurrentContext...
对我做错了什么有任何想法吗?
Any ideas as to what I'm doing wrong?
[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.barebonecoder.com/2010/10/nunit-and-the-new-testcontext-class/
Well...after no success diving into this exception I came across this post: http://www.barebonescoder.com/2010/10/nunit-and-the-new-testcontext-class/
从 nunit 的测试运行器运行我的测试是成功的...现在想知道如何使用 resharpers 测试运行器进行这项工作?
Running my test from nunit's test runner is successful...now to figure out how to make this work with resharpers test runner?
这篇关于NUnit TestContext.CurrentContext null 引用异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!