DEV Community

Mathilde Lelong for Agilitest

Posted on

Introduction to data-driven testing with Agilitest

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

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, an article by Paul Chevalier.

Top comments (0)