Introduction to data-driven testing with Agilitest
Tags: webdev, testing, devops, beginners
Published: 2022-09-07 13:54:41

_Automating software tests is an essential practice for setting up an Agile development process. In particular, the non-regression tests must be done in an automated way to free up time for the validation teams to automate new tests on the latest functionalities, or even to carry out exploratory testing._

_Since we are talking about automation, let's tackle a fundamental issue: the **variability** of tests using a** data file.** Welcome to what is called **data-driven testing** in software development._

## What is data-driven testing ?
Data-driven testing (or DDT) is a **software testing methodology** that uses an array of conditions to populate the test's **input data,** as well as its expected output data, and its environment and control variables.

The most simple way to set up DDT is to create a table in CSV format and assign one or more columns to input parameters and output data. Each row will represent a data set for an iteration of the test. This is precisely what we are going to do. It is also called table-driven testing or parameterized testing.

Data Driven Testing is strategic because testers frequently have multiple data sets for a single test and creating individual tests for each data set can be time-consuming and really challenging. Data driven testing helps separate data from test scripts and the same test scripts can be executed for different combinations of input test data. This way, test results can be generated efficiently.


![Image source: Guru99.com](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qfkyhm64bfa3ays2nmyu.png)

## Data-driven testing with Agilitest

## Create a project with a main ATS script
To get started, you need to create a new project or open an existing project.

We are going to create a main ATS script that will be used to **hook the DDT dataset to the actions of the test.** This ATS script will contain a Sub-script line which is configured with two basic data: the name of the script to open and the path to the CSV file.

## Create a CSV (or JSON) data file
You must therefore create a CSV file with the _New component_ button. The names of these files must match the names called in the main ATS script. To do this, simply drag and drop the CSV file into the _CSV file path_ box and the path will be relative to the root of the project, for example: _assets:///data/data.csv_

The CSV file is created and edited in Agilitest. Then you can edit this file with a classic text editor as long as you respect its syntax (CSV encoded in UTF-8 with comma field separator, double-quotes framing character, and CRLF line breaks). The file can also be generated by an external routine.

Agilitest also allows you to use a remote CSV file by entering a URL address instead of assets:///data/data.csv. The CSV file can then be generated dynamically by a small web application, or simply remain static remotely.

The fields of your CSV files can contain **texts to be entered** on the keyboard, **text to be recognized** on the application, or even **attributes** **to recognize** on the page (CSS classes or id, desktop attributes, etc.). Finally, they can contain values ​​to compare with fields in your application.

## Create a secondary ATS script
Read [full article here](https://www.agilitest.com/blog/introduction-to-data-driven-testing-with-agilitest), an article by Paul Chevalier.