MSTest / Seleniumを使用してC#でデータ駆動型テストを機能させようとしています。これは、それを設定しようとしている私のコードのいくつかのサンプルです:
[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」部分に下線を引いています。私は本当にこれに苦労してきました、ありがとう!