public class portal
{
public portal()
{
}
[DataSource ("Microsoft.VisualStudio.TestTools.DataSource.TestCase", "http://alm:8080/tfs/....", "15729", DataAccessMethod.Sequential), TestMethod]
public static void portalmtm()
{
BrowserWindow b = BrowserWindow.Launch(new System.Uri(TestContext.DataRow["portals"].ToString()));
}
public static TestContext TestContext
{
get
{
return testContextInstance;
}
set
{
testContextInstance = value;
}
}
private static TestContext testContextInstance;
}
}
它給當我使用它在codeduitest錯誤(TestMethod的) System.NullReferenceException:對象不設置到對象的實例。問題是什麼?我該怎麼辦?謝謝...編碼的UI測試System.NullReferenceException
[TestMethod]
public void Test1()
{
portalmtm();
this.UIMap....
this.UIMap....
}
public TestContext TestContext
{
get
{
return testContextInstance;
}
set
{
testContextInstance = value;
}
}
private TestContext testContextInstance;
您可以檢查http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-in-net –
TestContext永遠不會被初始化。 –
我編輯了代碼.. –