今天早上,我一直在使用watiN / Nunit来捕获失败的UI测试的屏幕截图。然而,我在访问Nunit 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)
{
}
}发布于 2011-03-20 03:52:54
Well...after没有成功深入研究这个异常我偶然发现了这篇文章:http://www.barebonescoder.com/2010/10/nunit-and-the-new-testcontext-class/
从nunit的测试运行器运行我的测试是successful...now,以弄清楚如何与resharpers测试运行器一起工作?
发布于 2011-03-20 02:19:49
是CurrentContext属性还是Result属性为NULL?可能是因为测试还没有完成,所以结果还没有设置。我正在使用WatiN/NUnit处理项目,我已经能够毫无问题地使用TestContext类,但我必须说我没有注意到Result属性的状态。
如果Result属性为空,那么可以尝试将浏览器的初始化移动到TestSetUp方法中,并在处置浏览器实例之前在TestTearDown中执行屏幕捕获。
https://stackoverflow.com/questions/5363635
复制相似问题