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

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
  1. Launch the application
  2. Enter Username password
  3. Click Okay
  4. Check Results
Username: valid password: valid Login Success

2 Check Login for invalid credentials
  1. Launch the application
  2. Enter Username password
  3. Click Okay
  4. Check Results
Username: invalid password: valid Login Fail

3 Check Login for invalid credentials
  1. Launch the application
  2. Enter Username password
  3. Click Okay
  4. Check Results
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:

  1. Allows to test application with multiple sets of data values during Regression testing
  2. Test data and verification data can be organized in just one file, and it is separate from the test case logic.
  3. 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.
  4. Actions and Functions can be reused in different tests.
  5. Some tools generate test data automatically. This is useful when large volumes of random test data are necessary, which helps to save the time.
  6. 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.
  7. Allows developers and testers to have clear separation for the logic of their test cases/scripts from the test data.
  8. The same test cases can be executed several times which helps to reduce test case and scripts.
  9. 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:

  1. Quality of the test is depended on the automation skills of the Implementing team
  2. Data validation is a time-consuming task when testing large amount of data.
  3. Maintenance is a big issue as large amount of coding needed for Data-Driven testing.
  4. High-level technical skills are required. A tester may have to learn an entirely new scripting language.
  5. There will be more documentation. Mostly related to scripts management tests infrastructure and testing results.
  6. 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的更多相关文章

  1. Spock - Document - 03 - Data Driven Testing

    Data Driven Testing Peter Niederwieser, The Spock Framework TeamVersion 1.1 Oftentimes, it is useful ...

  2. [转]Table-Driven and Data Driven Programming

    What is Table-Driven and Data-Driven Programming? Data/Table-Driven programming is the technique of ...

  3. Data Developer Center > Learn > Entity Framework > Get Started > Loading Related Entities

    Data Developer Center > Learn > Entity Framework > Get Started > Loading Related Entitie ...

  4. Python DDT(data driven tests)模块心得

    关于ddt模块的一些心得,主要是看官网的例子,加上一点自己的理解,官网地址:http://ddt.readthedocs.io/en/latest/example.html ddt(data driv ...

  5. Learn to Create Everything In a Fragment Shader(译)

    学习在片元着色器中创建一切 介绍 这篇博客翻译自Shadertoy: learn to create everything in a fragment shader 大纲 本课程将介绍使用Shader ...

  6. [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 ...

  7. spring data mongo API learn(转)

    显示操作mongo的语句,log4j里面加入: log4j.logger.org.springframework.data.mongodb.core=DEBUG, mongodb log4j.appe ...

  8. [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 ...

  9. [The Basics of Hacking and Penetration Testing] Learn & Practice

    Remember to consturct your test environment. Kali Linux & Metasploitable2 & Windows XP

随机推荐

  1. H.264 码率设置

    一.什么是视频码率 视频码率是视频数据(包含视频色彩量.亮度量.像素量)每秒输出的位数.一般用的单位是kbps. 二.设置视频码率的必要性 在网络视频应用中,视频质量和网络带宽占用是相矛盾的.通常情况 ...

  2. 使用UIVisualEffectView创建毛玻璃效果

    UIVisuaEffectView :继承自UIView,可以看成是专门用于处理毛玻璃效果的视图,只要我们将这个特殊的View添加到其他视图(eg. ImageView )上面,被该UIVisuaEf ...

  3. CCS V5 使用教程三:程序调试

    官网教程 新建调试工程 输入以下源码: #include <stdio.h> #include <c6x.h> ]; void main(void) { unsigned ; ...

  4. 如何在windows 2003(虚拟主机)上面部署MVC3

    相信有很多朋友和我一样遇到了这个问题,网上大牛说的都不是很清楚,关于这个问题我详细的跟进一下 这个问题呢大致分为两种情况 一.有服务器的控制权限,这个就简单很多, 1.安装mvc3支持组件2.如果可以 ...

  5. 怎么查看mysql的安装目录,环境:windows+mysql+navicat

    怎么查看mysql的安装目录 如果忘记了MySQL的安装目录,怎么快速找到呢?方法或许很多,作者觉得这种最方便了 环境:windows+mysql+navicat 方法:进入mysql命令行输入:sh ...

  6. ORA-12504:tns:监听程序在 CONNECT_DATA中未获得SERVICE_NAME

    在VS2008中创建一个数据源时,提示以下错误 “ORA-12504:tns:监听程序在 CONNECT_DATA中未获得SERVICE_NAME” 本机安装ORACLE客户端,找出以下路径的文件D: ...

  7. NodeJS”热部署“代码,实现动态调试(hotnode,可以实现热更新)

    NodeJS”热部署“代码,实现动态调试   开发中遇到的问题 如果你有 PHP 开发经验,会习惯在修改 PHP 脚本后直接刷新浏览器以观察结果,而你在开发 Node.js 实现的 HTTP 应用时会 ...

  8. R: 关于 table 函数的应用

    ################################################### 问题:关于 table 函数   18.5.9 来一个关于 table 函数的例子,说明tabl ...

  9. netty的引用计数

    netty的引用计数文档看http://netty.io/wiki/reference-counted-objects.html 为什么会引用引用计数呢,Java中不是有gc线程帮我们回收对象吗?我个 ...

  10. java多态和强制类型转换

    子类可以赋值给超类,称之为向上转型,这个是自动的. 超类不可以赋值给子类,这个是向下转型,需要我们手动实现. 赋值给超类的子类引用在运行期间将表现出不同的特性,这就是多态. 小类型    可转换为   ...