Data Driven Coded UI Test using Visual Studio 11

Posted by: Gouri Sohoni , on 4/10/2012, in Category Visual Studio
Views: 112572
Abstract: In this article, we will see how to convert normal Coded UI Test to Data Driven Coded UI Test using Visual Studio 11.

In this article, we will discuss in detail how to convert a normal Coded UI Test (CUIT) to Data Driven CUIT. CUIT is a new type of unit test introduced with Visual Studio 2010 Ultimate/Premium version. It provides functional testing for the user interface and the code gets created with the help of high level languages like C# or VB.NET.

If you are new to Coded UI Tests, make sure you read the following articles written for Visual Studio 2010.

Coded UI Test (CUIT) using Visual Studio 2010

Coded UI Test (CUIT) - Convert Manual Test Case to Code using Visual Studio 2010

Coded UI Test (CUIT) – Variations and Editing with Visual Studio 2010 and

Coded UI Test: Convert Normal CUIT to Data Driven CUIT using Visual Studio 2010.

Visual Studio 11 Beta can be downloaded from over here where all the SKUs (Ultimate, Premium, Professional or Test Professional) are available. Here is a snippet comparison between various SKUs and whether Coded UI Test support is available in them


The main difference while converting a normal CUIT to Data Driven CUIT with Visual Studio 11 is that there is no Data Source Wizard (which was available with Visual Studio 2010).


We will now create a normal CUIT and later convert it to Data Driven CUIT. For this we will use the example of a calculator and record addition of 2 numbers. We will use number keys to enter the numbers.

Follow these steps:

Step 1:  Open Visual Studio 11 > File > New Project.  A new project template for Coded UI Test project is available as shown


Step 2: As we are going to use the CUIT Builder, we will select the first radio button for creating a Coded UI Test (Record actions, edit UI map or add assertions)


Step 3: The CUIT Builder with a slightly changed look appears in the default position (right most bottom portion of the screen)


Step 4: Start Calculator


Step 5: Record addition of 2 numbers. Note: Do not use the mouse click to capture data as we do not get parameters with this action later


Following are the methods recorded.


We can also provide method description which will appear as a comment in the method


Step 6: With Visual Studio 11, we now have Unit Test Explorer which will show the available test methods. Run the test and verify that it gets executed without any error.

Step 7: Add a new item to the project. Provide NumData.xml as file name for the XML data file. Change the property for the file from Copy to Output Directory to “Copy if newer”


Step 8: We also need to provide the DataSource attribute to the method so as to specify the xml file as the data source. The parameters values can now to be taken from the data source as shown below


Step 9: Now run the test and we can observe that it passes for 2 records but fails for one.


Note: If you use a mouse click while entering numbers, no parameters will be automatically provided. This will also work only with single digit numbers.

In this article, we have seen how to convert normal Coded UI Test to Data Driven Coded UI Test using Visual Studio 11.

This article has been editorially reviewed by Suprotim Agarwal.

Absolutely Awesome Book on C# and .NET

C# and .NET have been around for a very long time, but their constant growth means there’s always more to learn.

We at DotNetCurry are very excited to announce The Absolutely Awesome Book on C# and .NET. This is a 500 pages concise technical eBook available in PDF, ePub (iPad), and Mobi (Kindle).

Organized around concepts, this Book aims to provide a concise, yet solid foundation in C# and .NET, covering C# 6.0, C# 7.0 and .NET Core, with chapters on the latest .NET Core 3.0, .NET Standard and C# 8.0 (final release) too. Use these concepts to deepen your existing knowledge of C# and .NET, to have a solid grasp of the latest in C# and .NET OR to crack your next .NET Interview.

Click here to Explore the Table of Contents or Download Sample Chapters!

What Others Are Reading!
Was this article worth reading? Share it with fellow developers too. Thanks!
Share on LinkedIn
Share on Google+

Gouri is a Trainer and Consultant on Azure DevOps and Azure Development. She has an experience of three decades in software training and consulting. She is a graduate from Pune University and PGDCA from Pune University. Gouri is a Microsoft Most Valuable Professional (MVP)  - Developer Technologies (Azure DevOps), Microsoft Certified Trainer (MCT) and a Microsoft Certified Azure DevOps Engineer Expert. She has conducted over 150 corporate trainings on various Microsoft technologies. She is a speaker with Pune User Group and has conducted sessions on Azure DevOps, SQL Server Business Intelligence and Mobile Application Development. Gouri has written more than 75 articles on Azure DevOps, TFS, SQL Server Business Intelligence and SQL Azure which are published on and You can connect with her on LinkedIn.

Page copy protected against web site content infringement 	by Copyscape

Feedback - Leave us some adulation, criticism and everything in between!
Comment posted by Sandeep K on Tuesday, November 6, 2012 6:37 AM
Hi Gouri Sohoni,

Could you please let me know the pros and cons of using an XML file as a data source against the SQL database.Will it impact the performance of the test case due to database interactions.
Comment posted by Hi Gouri Sohani on Wednesday, March 19, 2014 2:05 AM
Kindly let us know whether you are giving(or) providing any training on Coded UI for Desktop application.

Comment posted by sam on Wednesday, August 13, 2014 3:34 AM
Hi Gouri,
I am new to coded ui and i am planning to automate our application using coded ui. But i am little bit confused from where i have to start.
Is there any online training / book available.  
Comment posted by raj on Thursday, March 5, 2015 8:33 AM
most of them give calculator example
Can any one give example using API/WebService as Datasources ? or Datasource as C# Class or Bussiness logic method ?