What is Data Driven Testing? Learn to create Framework
What is Data Driven Testing?
Data-driven is a test automation framework which stores test data in a table or spread spreadsheet format. This allows automation engineers to have a single test script which can execute tests for all the test data in the table.
In this framework, input values are read from data files and are stored into a variable in test scripts. Ddt (Data Driven testing) enables building both positive and negative test cases into a single test.
In Data-driven test automation framework, input data can be stored in single or multiple data sources like xls, XML, csv, and databases.

In this tutorial, you will learn
- What is Data Driven Testing?
- Why Data Driven Testing?
- How to create a Data Driven Automation Framework
- Best practices of Data Driven testing:
- Advantages of Data-Driven testing
- Disadvantages of Data Driven testing:
Why Data Driven Testing?
Frequently we have multiple data sets which we need to run the same tests on. To create an individual test for each data set is a lengthy and time-consuming process.
Data Driven Testing framework resolves this problem by keeping the data searate from Functional tests. The same test script can execute for different combinations of input test data and generate test results.
Example:
For example, we want to test the login system with multiple input fields with 1000 different data sets.
To test this, you can take following different approaches:
Approach 1) Create 1000 scripts one for each dataset and runs each test separately one by one.
Approach 2) Manually change the value in the test script and run it several times.
Approach 3) Import the data from the excel sheet. Fetch test data from excel rows one by one and execute the script.
In the given three scenarios first two are laborious and time-consuming. Therefore, it is ideal to follow the third approach.
Thus, the third approach is nothing but a Data-Driven framework.
How to create a Data Driven Automation Framework

Consider you want to Test Login functionality of an application.
Step 1) Identify the Test Cases
- Input Correct username and password – Login Success
- Input incorrect username and correct password – Login Failure
- Input correct username and incorrect password - Login Failure
Step 2) Create detailed est Steps for above 3 Test Cases
| Test Case# | Description | Test Steps | Test Data | Expected Results |
|---|---|---|---|---|
| 1 | Check Login for valid credentials |
|
Username: valid password: valid | Login Success |
| 2 | Check Login for invalid credentials |
|
Username: invalid password: valid | Login Fail |
| 3 | Check Login for invalid credentials |
|
Username: valid password: invalid | Login Fail |
Step 3) Create Test Script
If you observe the Test Steps Remain common through the 3 Test Steps. You need to create a Test Script to execute these steps
// This is Pseudo Code // Test Step 1: Launch Application
driver.get("URL of the Appliation"); // Test Step 2: Enter Password
txtbox_username.sendKeys("valid"); // Test Step 3: Enter Password
txtbox_password.sendKeys("invalid"); // Test Step 4: Check Results
If (Next Screen) print success else Fail
Step 4) Create an excel/csv with the Input Test Data

Step 5) Step Modify the Scrip to Loop over Input Test Data. The input commands should also be parameterized
// This is Pseudo Code
// Loop 3 Times
for (i = 0; i & lt; = 3; i++) {
// Read data from Excel and store into variables
int input_1 = ReadExcel(i, 0);
int input_2 = ReadExcel(i, 1); // Test Step 1: Launch Application
driver.get("URL of the Application"); // Test Step 2: Enter Password
txtbox_username.sendKeys(input_1);
// Test Step 3: Enter Password txtbox_password.sendKeys(input_2);
// Test Step 4: Check Results
If(Next Screen) print success
else Fail
}
Above are just 3 test cases. The test script can be used to loop over following test cases just by appending test data values to Excel
- Input incorrect username and incorrect password – Login Fail
- Input correct username and password blank – Login Fail
- Input blank username and blank password– Login Fail
And so on
Best practices of Data Driven testing:
Below given are Best testing practices for Data-Driven testing:
- It is ideal to use realistic information during the data-driven testing process
- Test flow navigation should be coded inside the test script
- Drive virtual APIs with meaningful data
- Use Data to Drive Dynamic Assertions
- Test positive as well as negative outcomes
- Repurpose Data Driven Functional Tests for Security and Performance
Advantages of Data-Driven testing
Data-Driven offer many advantages some of them are:
- Allows to test application with multiple sets of data values during Regression testing
- Test data and verification data can be organized in just one file, and it is separate from the test case logic.
- Base on the tool, it is possible to have the test scripts in a single repository. This makes the texts easy to understand, maintain and manage.
- Actions and Functions can be reused in different tests.
- Some tools generate test data automatically. This is useful when large volumes of random test data are necessary, which helps to save the time.
- Data-driven testing can perform any phase of the development. A data-driven test cares are generally merged in the single process. However, it can be used in multiple test cases.
- Allows developers and testers to have clear separation for the logic of their test cases/scripts from the test data.
- The same test cases can be executed several times which helps to reduce test case and scripts.
- Any changes in the test script do not effect the test data
Disadvantages of Data Driven testing:
Some Drawbacks of Data Driven Automation Testing method are:
- Quality of the test is depended on the automation skills of the Implementing team
- Data validation is a time-consuming task when testing large amount of data.
- Maintenance is a big issue as large amount of coding needed for Data-Driven testing.
- High-level technical skills are required. A tester may have to learn an entirely new scripting language.
- There will be more documentation. Mostly related to scripts management tests infrastructure and testing results.
- A text editor like Notepad is required to create and maintain data files.
Conclusion:
- Data-driven is a test automation framework which stores test data in a table or spread spreadsheet format.
- In Data-driven test automation framework, input data can be stored in single or multiple data sources like xls, XML, csv, and databases.
- To create an individual test for each data set is a lengthy and time-consuming process. Data Driven Testing framework resolves this issue by keeping the data separate from Functional tests.
- In Data Driven Testing, it is an ideal option to use realistic information
- It allows testing application with multiple sets of data values during Regression testing
- Drawback of this method is that it is depended on the automation skills of the Implementing team
What is Data Driven Testing? Learn to create Framework的更多相关文章
- Spock - Document - 03 - Data Driven Testing
Data Driven Testing Peter Niederwieser, The Spock Framework TeamVersion 1.1 Oftentimes, it is useful ...
- [转]Table-Driven and Data Driven Programming
What is Table-Driven and Data-Driven Programming? Data/Table-Driven programming is the technique of ...
- Data Developer Center > Learn > Entity Framework > Get Started > Loading Related Entities
Data Developer Center > Learn > Entity Framework > Get Started > Loading Related Entitie ...
- Python DDT(data driven tests)模块心得
关于ddt模块的一些心得,主要是看官网的例子,加上一点自己的理解,官网地址:http://ddt.readthedocs.io/en/latest/example.html ddt(data driv ...
- Learn to Create Everything In a Fragment Shader(译)
学习在片元着色器中创建一切 介绍 这篇博客翻译自Shadertoy: learn to create everything in a fragment shader 大纲 本课程将介绍使用Shader ...
- [Jest] Write data driven tests in Jest with test.each
Often, we end up creating multiple unit tests for the same unit of code to make sure it behaves as e ...
- spring data mongo API learn(转)
显示操作mongo的语句,log4j里面加入: log4j.logger.org.springframework.data.mongodb.core=DEBUG, mongodb log4j.appe ...
- [D3] Start Visualizing Data Driven Documents with D3 v4
It’s time to live up to D3’s true name and potential by integrating some real data into your visuali ...
- [The Basics of Hacking and Penetration Testing] Learn & Practice
Remember to consturct your test environment. Kali Linux & Metasploitable2 & Windows XP
随机推荐
- C\C++的转义字符
C\C++的转义字符 所有的ASCII码都可以用"\"加数字(一般是8进制数字)来表示.而C中定义了一些字母前加"\"来表示常见的那些不能显示的ASCII字符, ...
- 基于libRTMP的流媒体直播之 AAC、H264 推送
这段时间在捣腾基于 RTMP 协议的流媒体直播框架,其间参考了众多博主的文章,剩下一些细节问题自行琢磨也算摸索出个门道,现将自己认为比较恼人的 AAC 音频帧的推送和解析.H264 码流的推送和解析以 ...
- OpenAL播放pcm或wav数据流-windows/ios/android(一)
OpenAL播放pcm或wav数据流-windows/iOS/Android(一) 最近在研究渲染问题,本文采用openal做pcm和wav数据流播放,并非本地文件,demo是windows的,i ...
- 【Google】循环字符串里面的独立子串
转载自九章算法(地址) 题目: 假设s是一个无限循环的字符串”abcdefghijklmnopqrstuvwxyz”,s就是一个”...zabcdefghijklmnopqrstuvwxyza...” ...
- Deferred Shading延迟渲染
Deferred Shading 传统的渲染过程通常为:1)绘制Mesh:2)指定材质:3)处理光照效果:4)输出.传统的过程Mesh越多,光照处理越费时,多光源时就更慢了. 延迟渲染的步骤:1)Pa ...
- 使用MDI窗体实现多窗口效果
本文章已收录于: C#MDI窗体实现多窗口效果 Visual C#是微软公司推出的下一代主流程序开发语言,他也是一种功能十分强大的程 序设计语言,正在受到越来越多的编程人员的喜欢.在Visua ...
- Linux编程之错误代码
头文件/usr/include/asm-generic/errno-base.h定义错误码: #ifndef _ASM_GENERIC_ERRNO_BASE_H #define _ASM_GENERI ...
- UML核心元素--用例
定义:用例定义了一组用例实例,其中每个实例都是系统所执行的一些列操作,这些操作生成特定主角可以观测的值.一个完整的用例定义由参与者.前置条件.场景.后置条件构成. 1.理解用例:用例就是参与者希望通过 ...
- JavaScript中对象的属性
在JavaScript中,属性决定了一个对象的状态,本文详细的研究了它们是如何工作的. 属性类型 JavaScript中有三种不同类型的属性:命名数据属性(named data properties) ...
- Python命令模块argparse学习笔记(四)
默认参数 ArgumentParser.set_defaults(**kwargs) set_defaults()可以设置一些参数的默认值 >>> parser = argparse ...