C# 编码的UI测试系统。NullReferenceException
当我在codeduitest(testmethod)中使用它时,它给出了一个错误 System.NullReferenceException:对象引用未设置为对象的实例。有什么问题?我能做什么?谢谢C# 编码的UI测试系统。NullReferenceException,c#,visual-studio-2010,coded-ui-tests,C#,Visual Studio 2010,Coded Ui Tests,当我在codeduitest(testmethod)中使用它时,它给出了一个错误 System.NullReferenceException:对象引用未设置为对象的实例。有什么问题?我能做什么?谢谢 public class portal { public portal() { } [DataSource ("Microsoft.VisualStudio.TestTools.DataSource.TestCase", "http://alm:8080/tfs
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;
}
}
类必须用
codeduiteStatAttribute
属性修饰。类必须用codeduiteStatAttribute
属性修饰。像这样将[TestMethod]放在方法之上,它应该可以工作。(TestMethod)没有任何意义,必须使用方括号
[TestMethod]
public void Test1()
{
portalmtm();
this.UIMap....
this.UIMap....
}
public TestContext TestContext
{
get
{
return testContextInstance;
}
set
{
testContextInstance = value;
}
}
private TestContext testContextInstance;
顺便说一句,如果你打算在这里放置任何自动测试方法,我很确定它不会是静态的。将[TestMethod]放置在这样的方法之上,它应该可以工作。(TestMethod)没有任何意义,必须使用方括号
[TestMethod]
public void Test1()
{
portalmtm();
this.UIMap....
this.UIMap....
}
public TestContext TestContext
{
get
{
return testContextInstance;
}
set
{
testContextInstance = value;
}
}
private TestContext testContextInstance;
顺便说一句,如果你打算在这里使用任何自动测试方法,我很确定它不会是静态的。你可以检查
TestContext
从未初始化。你的CodedUiTest在哪里?您已经将其定义为一个简单的TestMethod。如何初始化testcontext?您可以检查testcontext
从未初始化。您的CodedUiTest在哪里?您已经将其定义为一个简单的TestMethod。如何初始化testcontext?