I am trying to do Unit Testing with Excel as data source. I am getting the following exception. How do we correct it?
The unit test adapter failed to connect to the data source or to read the data. For more information on troubleshooting this error, see "Troubleshooting Data-Driven Unit Tests"
[TestMethod]
[Owner("Lijo ")]
[TestProperty("TestCategory", "Developer"),
DataSource("Microsoft.ACE.OLEDB.12.0",
"Data Source=C:/Sheets/DataSheet.xlsx;Extended Properties=Excel 12.0;",
"[Sheet1$]",
DataAccessMethod.Sequential)]
public void ChangePasswordTest()
{
int a = Convert.ToInt32(TestContext.DataRow[0]); //(int)Column.UserId
int b = Convert.ToInt32(TestContext.DataRow[1]);
int expectedResult = Convert.ToInt32(TestContext.DataRow[2]);
MyClass myObj = new MyClass(1, "P@ssw0rd");
int actualResult = myObj.GetAdditionResult(a, b);
Assert.AreEqual<int>(expectedResult, actualResult, "The addition result is incorrect.");
}
Readings:
Unit Testing Error - The unit test adapter failed to connect to the data source or to read the data
How to create Startup and Cleanup script for Visual Studio Test Project?
How Does MSTEST/Visual Studio 2008 Team Test Decide Test Method Execution Order?
Visual Studio 2010 Ultimate - Data Generation Plan Setting Incorrect Data Type for Column