我想要使用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