我想要使用MSTest/Selenium在C#中进行数据驱动测试。 下面是一些我的代码试图将其设置一个样品:MSTest中的数据驱动测试问题
[TestClass]
public class NewTest
{
private ISelenium selenium;
private StringBuilder verificationErrors;
[DeploymentItem("GoogleTestData.xls")]
[DataSource("System.Data.OleDb",
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=GoogleTestData.xls;Persist Security Info=False;Extended Properties='Excel 8.0'",
"TestSearches$", DataAccessMethod.Sequential)]
[TestMethod]
public void GoogleTest()
{
selenium = new DefaultSelenium("localhost", 4444, "*iehta", http://www.google.com);
selenium.Start();
verificationErrors = new StringBuilder();
var searchingTerm = TestContext.DataRow["SearchingString"].ToString();
var expectedResult = TestContext.DataRow["ExpectedTextResults"].ToString();
...
这是我的错误: 错误3的对象引用是所必需的非静态字段,方法或属性“Microsoft.VisualStudio .TestTools.UnitTesting.TestContext.DataRow.get'E:\ Projects \ SeleniumProject \ SeleniumProject \ MaverickTest.cs 32 33 SeleniumProject
错误突出显示了两个语句的“TestContext.DataRow”部分。 我真的一直在努力与这一个,谢谢!
我不知道如何获取代码中有没有它得到宰割?对不起大家 – Jacob 2010-06-07 21:31:09