Reputation: 159
I have written a data-driven unit test and now I need to specify the data source for the unit test. The unit test is written in C# with MS Visual Studio. My data source is an excel file with a sheet named "TestData". My code for data source is as follows:
[DataSource(
"System.Data.Odbc",
"Dsn=Excel Files;dbq=.\data.xlsx;defaultdir=.; driverid=790;maxbuffersize=2048;pagetimeout=5",
"TestData$",
"Sequential"
)]
What's wrong and how to fix it?
Upvotes: 0
Views: 1669
Reputation: 6508
You need to run Visual Studio Data Source Wizard to run the tests. Click here to See the Youtube Video
Upvotes: 0
Reputation: 3138
You can put ConnectionString in Config file and add to Attribute
<connectionStrings>
<add name="MyExcelConn" connectionString="Dsn=Excel Files;dbq=.\data.xlsx;defaultdir=.; driverid=790;maxbuffersize=2048;pagetimeout=5" providerName="System.Data.Odbc" />
</connectionStrings>
Then add to your update your attribute:
[DataSource("MyExcelDataSource")]
Upvotes: 1