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