Using Multiple dataSources in data driven test
-
Tuesday, January 31, 2012 6:00 AM
Hi All,
My requirement is,i need to get data from Excel sheet....Here i have a sheet called Contact.And on the fields in that sheet is Address which is being refered to ID in the Address sheet.Now i need to get info regarding Address based on the Id that is refered in the Contact Sheet(Address sheet is just like Foriegn Key table)...Can some one pls guide me how to retrive this using mutliple datasource..A bit of code is as follows
[TestMethod]
[DeploymentItem("LoadExcel\\ExcelData\\TestData.xlsx")]
[DataSource("ContactDataSource")]
public void TestMethod1()
{}Connection string in config file looks like:
<connectionStrings>
<add name="MyExcelConn" connectionString=" Driver={Microsoft Excel Driver (*.xlsx)};Dsn=Excel Files;dbq=E:\wpf_code_samples\LoadExcel\LoadExcel\ExcelData\TestData.xlsx;defaultdir=.; driverid=790;maxbuffersize=2048;pagetimeout=5;Readonly=0" providerName="System.Data.Odbc" />
</connectionStrings>
<microsoft.visualstudio.testtools>
<dataSources>
<add name="ContactDataSource" connectionString="MyExcelConn" dataTableName="Contact$" dataAccessMethod="Sequential"/>
</dataSources>
</microsoft.visualstudio.testtools>Thanks in advance
All Replies
-
Wednesday, February 01, 2012 7:22 AMModerator
Hi mohanram_poola,
Thank you for posting in the MSDN forum.
Do you mean that you want to use multiple datasources for a single unit test?We can create two unit tests and have the separate datasource for each. But we cannot have multiple datasource for a single unit test. Because the concept for data-driven is that the unit test runs once per row in the data source where the data points are parameters to the test.
Reference:
http://social.msdn.microsoft.com/Forums/en-US/vststest/thread/8f05ca17-f751-4ad6-920c-54fa56fc8f28
Best Regards,
Jack Zhai [MSFT]
MSDN Community Support | Feedback to us
- Marked As Answer by mohanram_poola Wednesday, February 01, 2012 1:17 PM
-
Wednesday, February 01, 2012 1:18 PMThak you very much..

