【发布时间】:2011-03-19 17:32:07
【问题描述】:
今天早上我一直在玩 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)
{
}
}
【问题讨论】: