Data Driven Testing with Visual Studio 2012 – Coded UI Test


In Visual Studio 2010 we use Test View Window and Data Source Wizard to create data driven Coded UI test case.

In Visual Studio 2012, the Test View Window and Data Source Wizard are no longer available.

You will have to insert the [Data Source] attribute directly in the code in the line immediately above your [Test Method].

Sample Data Source strings are given below. Copy them to your code and make the necessary customizations.

Data Source Type Data Source attribute
CSV [DataSource(“Microsoft.VisualStudio.TestTools.DataSource.CSV”, “|DataDirectory|\\data.csv”, “data#csv”, DataAccessMethod.Sequential), DeploymentItem(“data.csv”), TestMethod]
Excel DataSource(“System.Data.Odbc”, “Dsn=Excel Files;Driver={Microsoft Excel Driver (*.xls)};dbq=|DataDirectory|\\Data.xls;defaultdir=.;driverid=790;maxbuffersize=2048;pagetimeout=5;readonly=true”, “Sheet1$”, DataAccessMethod.Sequential), TestMethod]
Test Case in TFS [DataSource(“Microsoft.VisualStudio.TestTools.DataSource.TestCase”, “http://vsalm:8080/tfs/DefaultCollection;FabrikumFiber”, “30”, DataAccessMethod.Sequential), TestMethod]
XML [DataSource(“Microsoft.VisualStudio.TestTools.DataSource.XML”, “|DataDirectory|\\data.xml”, “Iterations”, DataAccessMethod.Sequential), DeploymentItem(“data.xml”), TestMethod]
SQL Express [DataSource(“System.Data.SqlClient”, “Data Source=.\\sqlexpress;Initial Catalog=tempdb;Integrated Security=True”, “Data”, DataAccessMethod.Sequential), TestMethod]
Other types here

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.