Data-driven runs

Run the same flow once per row of a CSV or JSON file. Each column becomes a variable, so one flow tests many users, inputs or edge cases, each with the answer it expects.

Example flow

examples/Help/data-driven.clem.json logs in once per row of files/logins.csv: three valid users that expect 200, and a wrong password that expects 400.

examples/Examples/18_data_from_json.clem.json does the same from a JSON file, files/products.json, whose values keep their types: numbers, booleans and lists.

The data file

username,password,expectedStatus,firstName,note
emilys,emilyspass,200,Emily,valid login
michaelw,michaelwpass,200,Michael,valid login
sophiab,sophiabpass,200,Sophia,valid login
emilys,not-her-password,400,,wrong password is refused

A column user (or $user) is the variable $user, usable anywhere a variable works.

Setting it up

Flow Settings (the gear in the title bar) → Data-driven runs → Data file. Pick the file with Browse (a file from elsewhere can be copied into the project's files folder). The panel shows the whole file as a table.

Flow Settings, Data-driven runs section, with logins.csv shown as a table
The data file in Flow Settings.

Edit opens it in a grid: change any cell or column name, add or remove rows and columns, and Save writes it back in its own format (CSV keeps its separator; JSON keeps its value types). Enter or ↓ moves to the next row.

Use the columns in the steps. In the example, the login's check is status equals $expectedStatus, and the greeting step has the run conditional $expectedStatus == 200, so it only runs for valid logins.

How the rows run

The run log with one block per data row and the totals at the end
One block per row: passed rows fold up, failed ones stay open.

Reports show each row with its steps, JUnit XML has a test suite per row (Login [row 2: bob]), and the JSON summary lists every row.

In exported flows

An export takes the data file along (in <name>.files) and runs it by default.

node logins.js                     # every row of the flow's own file
node logins.js --data other.csv    # another file (relative to the current folder)
node logins.js --data none         # once, without data

clem-suite.js passes --data to every flow.