Reuse values with variables and chaining

Use {{name}} variables, keep secrets masked, and pass a value from one test to the next.

In short

Write {{name}} in a test's SQL or a parameter value and the environment's variable of that name is used, so one test runs on Local and QA with different values. An Extract rule copies a value from one run into a variable that the next test reads.

Before you start

Use a variable

  1. Add the variable to the environment, with a value. Tick "Secret" for passwords and tokens.
  2. Write {{name}} in the test's SQL or in a parameter value.
  3. To override it for one run, type a value in "Variables for this run".

Pass a value to the next test

  1. In test A, add an extraction under "Extract values": Variable invoiceId, From Output parameter, Path NewInvoiceId. Set Chain order 1.
  2. In test B, set a parameter to {{invoiceId}} and Chain order 2.
  3. On the Tests board, tick "Run all tests in order (chained)" and press "Run all tests".

Rollback breaks chains Each test is its own transaction. If A rolls back, B will not find the invoice A created. Put the setup in B's Setup SQL, or run A with Commit on a Local, Development or QA database you may change.

Good to know

If something goes wrong

Related