It is not too hard to set it up, all that is required is addition of DataSourceAttribute to your test method:
[TestMethod]
[DeploymentItem("testData.xls")]
[DataSource(“System.Data.Odbc”,
@”Driver={Microsoft Excel Driver (*.xls)};DriverId=790;Dbq=testData.xls;DefaultDir=.”,
“Sheet1$”, DataAccessMethod.Sequential)]
public void SomeTest(){
//some testing
}
DeploymentItemAttribute is there so testData.xls file would be deployed with the test and thus make the test independent of a machine on which it is run. More about using Excel to drive your unit tests with some tips you can find here: Data-Driven Unit Testing using Excel in Visual Studio.
Comments