ExecuteAutomation

Data Driven Testing in Coded UI Test Record and Playback

Data Driven Testing is one of the most useful part in any automation testing tool, it can be any testing tool like Selenium, QTP or Test Complete, we do data driven automation testing with it. Data Driven testing in Coded UI Testing is done especially to replace the hard coded value with external data source. The external data source can be either a All the above data sources are supported in Coded UI testing.

Working with Data Driven Testing

In this post, we are going to use CSV (Comma Separated Value) file as external data source and using TestContext property of Coded UI class to populate data into our code. Hence, we need to perform following steps to make our testing data driven
Creating External Data Source
Adding Data Source Attribute
Using TestContext.Data[] to retrieve the data from external data source and passing it

Creating External Data Source

To Create External data source, first add a new file using New à File Then enter the Data into the CSV file as shown As you can see above, I am creating two columns, first column indicates the operation which we are going to perform, in our case we are going to just add two number and we are going to verify if its output is same as “Result” column.

Adding Data Source Attribute

Next add, the data source attribute for CSV as shown below As you can see above, the data source is CSV and the DataDirectory is \\data.csv, which is nothing but our data.csv file.

Retrieving Data using TestContext.DataRow

We can retrieve the data from data source using the following code As you can see above, I have create a AssertMethod to verify if the Result in actual application is generating the value which we specified in the CSV file

Assertion Code

The assertion code to verify if the value in calculator result for 89 + 23 = 112 is same as CSV   Please watch the full explanation of article as Video to fully understand the concept with in-depth details. Please leave your comments and thanks for reading and watching the article. Thanks, Karthik KK