Skip to content
Get Free Trial

Test Data Files

Keep test data in groups in a .csv test data file, edit it as a sheet, and attach it to a test case or keyword with Data Drive.

A test case that runs with one set of values only checks one case. To check the same flow with many sets of data, such as several orders, put the values in a test data file. Sahi Pro then runs the test case once for each row.

A test data file is a .csv file that keeps its rows in groups, so one file can hold several sets of data, such as everyday orders and bulk orders.

  1. Choose File > New > Test Data, or click + in the Navigator and choose Test Data.

  2. Enter the Test Data File Name, such as book_orders, and click Create. The file is created in the project, shown under File Location.

    The Create Test Data dialog with Test Data File Name book_orders followed by .csv, File Location sahi_training/, and the Cancel and Create buttons
  3. The file opens as a sheet. Enter each group:

    book_orders.csv open as a sheet with two groups: valid_orders with the columns Username, Password, javaQty, rubyQty, pythonQty and total and three rows of orders, a blank row, then bulk_orders with the same columns and two rows; numbered badges mark the group name, the column names, the rows and the blank row
    1. Group name, in the first column of the group’s first row, such as valid_orders.
    2. Column names, in the same row. Name each column after the parameter it fills, without the $, such as Username for $Username.
    3. Rows, one for each run, with the first column left empty.
    4. A blank row before the next group, such as bulk_orders.
  4. Save with Ctrl + S (⌘ + S on Mac).

The toolbar above the sheet has:

The toolbar above the test data sheet, with numbered badges on Find and Replace, Save File, the more-options button and Script Information
  1. Find and Replace: finds and replaces values in the sheet.
  2. Save File: saves the file. It’s available once you’ve made a change.
  3. More options: Keyboard Shortcuts (Shift + F10) lists the sheet’s shortcuts.
  4. Script Information: shows the file’s path.

Right-click a column letter to insert a column to its left or right, or remove the column:

Column D selected in the test data sheet, with its right-click menu: Insert column left, Insert column right and Remove column available, and Insert row above, Insert row below, Remove rows, Undo and Redo greyed out

Right-click a cell, or a row number, to insert a row above or below it, insert a column to its left or right, or remove its row or column. Undo and Redo undo and redo your last changes.

A cell in the pythonQty column selected in the test data sheet, with its right-click menu: Insert row above, Insert row below, Insert column left, Insert column right, Remove row, Remove column, Undo and Redo
  1. In the No-Code Test Editor, tick the test case that should loop through the data, and click Data Drive. To loop through only one keyword, tick that keyword instead.
  2. Choose Existing File and pick the Test Data File.
  3. Choose the Group Name. + beside it adds a new group to the file.
  4. Under Column Name, the columns that match the test case’s parameters are ticked. Check that each parameter has a column.
  5. Click Confirm.
The Data Drive - Link Test Data Sheet dialog with Existing File chosen, Test Data File book_orders.csv, File Path sahi_training/, Group Name valid_orders highlighted with a + button beside it, Generate New Values chosen, and the columns Username and Password ticked with the values test and secret

When you run the test case, it runs once for each row of the group, and the report shows a result for each row. New File in the same dialog creates a test data file and its group without leaving the test case. Generate Values applies only to cells with a data generator: Reuse Previous Values lets a verification keyword check the values an earlier keyword created. For a walkthrough, see Loop Through a Test Data File.