Many times, there are a number of data sets that we have to run the same tests on. And, to create a different test for each data set values is time-consuming and inefficient.
Data Driven Testing overcomes this issue by keeping the data external to Functional tests and loading them when there is a need to extend the automation tests.
In this tutorial, we will discuss Data Driven Testing – What it is, how it works, pros & cons, etc.
What You Will Learn:
Data Driven Testing is a Test design and execution strategy where the test scripts read test data from data sources (file or database) such as ADO objects, ODBC sources, CSV files, etc. rather than using hard-coded values.
The setup and control of test environment in this process is not hard coded.
Also read => Most Popular Test Automation Frameworks
Some of the features of Data-Driven Scripts are:
Keyword Driven Test Automation often known as Table Driven Test Automation. This is an application independent automation framework where tests are developed in the form of a data table using keywords.
Some features of Keyword Driven Test Automation are:
Hybrid Test Automation Framework is the combination of Data Driven and Keyword Driven Automation Frameworks.
Example of DDT:
Let us see an example for Data Driven Testing. Consider the Login Page of a Flight Reservation website.
1) A test data file is created as TestData.csv (Comma Separated Values)
2) This file contains inputs given to the driver script and expected results shown in the table below;
3) The driver script for above data file will be,
data = open(‘TestData.csv’).read()
lines = data.splitlines()
4) Steps performed for above driver scripts are as follows;
5) Calculate the result using operator on Value1 and value2
6) Finally, compare the expected result with the actual result
To create a Data Driven Frameworks in QTP, the following components are required:
QTP supports the following data sources;
These are 3 methods to create Data Driven Framework in QTP:
1) Selenium Webdriver Data Driven Framework takes test input and output from ODBC sources, CVS files and Excel files.
2) The framework includes navigation through a program, reading the data files and logging test status.
3) The framework should have the following features:
=> Read this article to learn more about Data Driven Framework in Selenium with examples.
Creating Data Driven Tests using TestNG:
1) TestNG is a framework that makes Data Driven automation Testing possible in Selenium.
2) It is created with Junit with added features for performing regression automation testing
3) TestNG is a popular and widely used framework with Selenium Webdriver
4) It has some additional key features such as parameterization, parallel test execution etc and requires JDK 7 or higher
5) Some of the cool features of TestNG that makes it easier and efficient are:
6) DataProviders is a data feeder method which is defined in a class that provides test methods and test data
Also read => How to Perform Data Driven Testing using SoapUI
Data Driven Testing helps automated tests to run rapidly over an application with different input data and also provides large coverage to ensure the performance of an application. Data Driven Testing also enhances business intelligence by reducing risks, increasing ease of accessing and sharing information with real-time analysis.
It speeds up the decision-making process and in turn rapid automation testing. Quick navigation through data sets is also an important feature offered by Data Driven Testing reduces testing timelines for an AUT.
About Author: Sanjay Zalavadia – as the VP of Client Service for Zephyr, Sanjay brings over 15 years of leadership experience in IT and Technical Support Services. Throughout his career, he has successfully established and grown premier IT and Support Services teams across multiple geographies for both large and small companies.
Let us know if you have any queries about Data Driven testing strategy.