Data Driven Testing using a CSV file

AGILITEST offers its users to practice Data-Driver Testing as much to configure test campaigns as to adapt a script to its context and optimize test coverage via its dataset.

This goes through a specific function: The Agilitest editor allows you to pass a CSV file as a parameter of a sub-script call. Thereafter, during the replay of the test, the sub-script will be called as many times as there are lines in the CSV file, passing as input variables of the sub-script the values ​​of the columns of each line.

Here's how to do it:

  • Select the src/assets/data directory in the project explorer
Selecting the src/assets/data directory
  • Right-click and select "Create CSV file"
  • Enter the name of the CSV file: the file is created empty in the src/assets/data tree
  • Double click on the file to edit it: Agilitest edits your empty file
  • You can click on "Add parameter" to add a column to your file, and on "Add iteration" to add a line.

Add rows and columns

Subsequently, you can enter values ​​directly in the cells that have been created.

Edition of a CSV file
  • Create an action of type "Sub-script call"
  • Drag the CSV file directly from the "Project Explorer" area to your new "Call script" action: Agilitest takes this new CSV file into account when calling the sub-script.

Editing a sub-script call with CSV file in Agilitest

Once this file is completed, you can retrieve the variables in your sub-script by using the $param() function and passing the index of the column of the parameter that interests you.

For example: $param(0) returns the value of the first column.

Example of using the $param() function

Tip 1: you can combine $param calls with other text boxes to generate more complex texts. The above example will generate a button identifier "Btn1" from the value "1" passed as input.

Tip 2: you can give a default value in the $param function as a second variable, this allows you to use the sub-script as a directly usable script. Btn $param(2,1) will return Btn1 if the script was not called by a parent script.

Tip 3: To start testing your script, you can start by calling your subscript by passing hardcoded parameters.

call the sub-script with directly filled parameters

The video below summarizes the steps to create a CSV file and iterate over it with a sub-script.

To go further, you can consult our article on the interest of exploiting data-driven testing with Agilitest and which offers a webinar video on the subject.

Still require support?
Contact support