Data-driven testing (DDT) allows you to execute test cases using data from external data files in table or spreadsheet format. Katalon Recorder facilitates DDT by providing DDT commands and enabling you to bind test cases with data files.
Katalon Recorder version 5.6.0 onwards.
This article introduces you to the DDT commands and data file formats supported by Katalon Recorder.
Katalon Recorder provides two commands for DDT:
loadVars command starts a loop to repeatedly load the values from the data file specified in the Target field.
endLoadVars command terminates the data-driven block. You need to add it to your test; otherwise, you will get an error message.
Data-driven testing process
When you execute a test containing
endLoadVars commands, the following process will take place, with i starting with 1 and ending with the number of rows in the data file:
- The ith row of the data file will be fetched.
- The values of the row will be mapped to the variables used in the test case.
- The steps between
endLoadVarswill be executed using these mapped values.
Data file formats
Katalon Recorder supports two data file formats: CSV and JSON.
Data files in CSV format
While performing DDT with a CSV data file, Katalon Recorder navigates the file using the column names, and extracts data from the file, row by row. Therefore, you need to create a CSV file with specific column names.
Katalon Recorder also treats CSV column names as case-sensitive.
For example, a data-driven test that fills in a form with dates and comments might have a CSV data file as follows:
Data files in JSON format
Katalon Recorder uses JSON data files with specific syntax. Test data in a JSON file must be organized in an array. Each element (data row) in the array is represented as an object with name/value pairs; the name specifies the column name, and the value specifies the value in the respective row.
For example, a JSON data file with two columns, dates and comments, might be written as follows:
Katalon Recorder comes with a set of built-in sample projects to get you started with DDT.
Follow these steps to add a sample project:
In the Actions sidebar, select Sample Projects.
In the displayed dialog, select the Fill a form with data from CSV file with Sample Test Data sample project. Click Add to add the project.
The Katalon Academy course: Data-Driven Testing with Katalon Recorder.