Skip to content

Data-driven tests

Write a check once and run it over a table of values: ten amounts and the code each must get, a list of cards and their outcomes, the rows of a CSV a colleague exported. Each row is its own step in the result, named by its values, so a failing row is found at a glance.

name: Amounts and their codes
target: {simulated_host: Amount limits}
steps:
- name: The host answers by amount
rows:
- {amount: "1000", code: "00"}
- {amount: "25000", code: "00"}
- {amount: "90000", code: "51"}
send: {sample: auth, amount: "{{amount}}"}
expect: {fields: {39: "{{code}}"}}

The step runs once per row. A row’s columns are variables for that step: in what it sends, what it expects, and what it saves. {{row}} is the row’s number, handy for a terminal id or a reference that must differ per row (fields: {41: "ROW{{row}}"}). The run shows three steps: “The host answers by amount (amount=1000, code=00)” and so on.

Numbers go in quotes, as scenario variables do: YAML reads code: 00 as the number zero and the leading zero is lost. amount: takes a number or one {{variable}} holding one.

The same table as CSV text, the first line naming the columns. Export it from a spreadsheet and paste it:

- name: The same from a CSV
rows: |
amount,code
500,00
60000,51
send: {sample: auth, amount: "{{amount}}"}
expect: {fields: {39: "{{code}}"}}

CSV values are text as written, leading zeros included.

rows: on the scenario runs every step once per row, in order: all the steps for the first row, then all for the second.

name: Cards
target: {simulated_host: Issuer}
rows:
- {pan: "4111111111111111", code: "00"}
- {pan: "4000000000000002", code: "05"}
steps:
- name: Authorization
send: {sample: auth, pan: "{{pan}}", amount: 1000}
expect: {fields: {39: "{{code}}"}}
save: {approval: 38}
- name: Its reversal
send: {sample: auth, mti: "0400", pan: "{{pan}}", amount: 1000}

A step with its own rows: inside a scenario with rows: runs once per pair; the step’s row wins where both name a column, and {{row}} is the step’s row.

Every row is a step in the run, in the console, the CI client’s output and the JUnit report, named by the row’s values. The scenario page lists the expanded steps too. stop_on_failure: true stops at the first failing row.

  • Up to 1,000 rows in a table, and up to 2,000 steps in a run after the tables expand.
  • Rows don’t apply to a load (load: sends its mix) or a replay.
  • A column name is a variable name: letters, digits and _, not stan or row.