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.
Recommended IPTV Service Providers
- IPTVGREAT – Rating 4.8/5 ( 600+ Reviews )
- IPTVRESALE – Rating 5/5 ( 200+ Reviews )
- IPTVGANG – Rating 4.7/5 ( 1200+ Reviews )
- IPTVUNLOCK – Rating 5/5 ( 65 Reviews )
- IPTVFOLLOW -Rating 5/5 ( 48 Reviews )
- IPTVTOPS – Rating 5/5 ( 43 Reviews )
In this tutorial, we will discuss Data Driven Testing – What it is, how it works, pros & cons, etc.
What You Will Learn:
- What Is Data-Driven Testing?
What Is Data-Driven Testing?
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
Data Driven Script
Some of the features of Data-Driven Scripts are:
- Identification of Variable Data and Hard Coded Components: When Test scripts contain hard coded components, they break with application’s change. Therefore, find ways to incorporate variable data. However, not everything can be variable, so a data-driven script often consists both variable and hard coded areas. It is the capability of the automation tester to design scripts with the right balance of both.
- Duplicate Test Design: In Data Driven Scripts all application designs are developed using scripting language. It is duplicated in both manual and automated test scripts for synced up references for both automation and manual testers.
Keyword Driven Test Automation
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:
- Reusable Code, Error Correction, and Synchronization: Application Independent Components constructed accept application specific data. These components can be reused for all applications to be tested.
- All in One Record: All in One Record refers to actions to be performed, the expected results and actual results.
Hybrid Test Automation
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;
- Read Value1
- Read Value2
- Read Operator
5) Calculate the result using an operator on Value1 and value2
6) Finally, compare the expected result with the actual result
Data Driven Framework In QTP
To create a Data Driven Frameworks in QTP, the following components are required:
- Test Script and Object Repository: For reading data and applying it on the AUT from external sources
- External Data Source: Contains test data required for test scripts to run.
QTP supports the following data sources;
- Excel Files
- Text Files
- XML Files
These are 3 methods to create Data Driven Framework in QTP:
- Method 1 uses QTP and Data table where all data in QTP is saved and retrieved from data tables.
- Method 2 uses QTP, Data table and Excel files where QTP copies data from Excel files to the data table and uses built-in method to access data in the data table.
- Method 3 uses QTP and Excel files where all data is saved in Excel files and QTP reads data directly from Excel files using built-in methods.
Selenium Webdriver Data Driven Framework
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:
- Less time to test large data sets
- Easier, rapid and efficient analysis
- Easy debugging
- Well defined architectural design
- Robust, stable and reliable
- Easy script maintenance
- Script execution in multiple test environment
=> 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:
- Flexible Test Configuration
- Default JDK functions
- Supported by a variety of tools and plug-ins
- Support for parameters
- Support for Data-Driven testing using DataProviders
- Powerful and safe Execution Model
- Used to perform all categories of testing
6) DataProviders is a data feeder method which is defined in a class that provides test methods and test data
Advantages of Data-Driven Testing
- Possibility to create Test scripts at the development stage of an application
- Redundancy and unnecessary duplication of test scripts are reduced
- Generates test scripts with less amount of code
- All information like inputs, outputs, and the expected result is stored in the form of appropriately managed text records
- Provides flexibility in application maintenance
Disadvantages of Data Driven Testing
- Requires great expertise of scripting language
- Requires large no. of data files for each test case with many inputs
- For creating a new test case it requires a new driver script with different data such that the changes made to test case should reflect in the driver script or vice versa
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.