Data-Driven Testing: What, why, when, and how

What is Data-Driven Testing?

Data-driven testing, which is also known as table-driven or parameterized testing, is a testing methodology where the test scripts or test data are read from data files instead of hardcode values. Hardcode values are the ones that are manually entered while writing the test steps. 

A data file contains input data and the respective verifiable output data in a table format. As the test runs, the data is taken from the table in a row-wise order. This process is repeated until all the given row data are taken and tested; also referred to as iterations. During the first iteration, the first row data will be taken for testing, then the second row, followed by the third row, until the number of rows specified is completed. 

How to do it?

We just saw that for data-driven testing (DDT), we need the data files. So the tester has to import the data file into the testing application and associate it with the test case which will use the data. This will help the tester handle bulk data effectively.

The data file can be in the form of :

  • Data pools: a related set of values obtained from a central database. 
  • Excel files: a spreadsheet application in which the data is organized and stored in rows and columns. 
  • ADO objects: ActiveX Data Objects create an open connection to a data source. 
  • CSV files: Each line in a Comma-Separated Values file is a data record where commas separate one or more fields.
  • ODBC sources: Open Database Connectivity is an interface that lets the applications access data stored in the database management systems with the help of SQL. 

When can we use DDT?

In a situation where the same test step has to be automated and repeated multiple times with different versions of the data and its expected outcome, we go for data-driven testing. 

For instance, we are testing the username and password field on a login or signup page. It involves testing multiple data that range from valid to invalid credentials. This is done to check whether or not the field is working as expected. 

Instead of manually entering multiple hardcode values in DDT to check if it works, we feed the data to the testing software to enable the data-driven test, where each data set is automatically taken and tested in each iteration. 

Why is it important?

There are multiple advantages to why you should go for data-driven testing while dealing with bulk data. 

  • It helps in improving the effectiveness of your testing. 
  • It helps to avoid duplication and saves time.
  • It makes the process more efficient and organized.
  • If there are changes made to the test data, it does affect the test process. 
  • It helps testers and developers keep track of the data and test flow, point out errors, and work on them.

So based on the nature and requirements of the test, data-driven testing is used, which helps in better test coverage and saves time. 

Leave a Comment

%d bloggers like this: