Skip to main content

Test file format

A test is a YAML (or JSON) file. Unknown fields are rejected, so a typo is reported by teststream tests validate.

name: Empty cart cannot check out
description: Checkout is refused when nothing is in the cart.
role: standard_user
start: /inventory.html
folder: Checkout
tags: [smoke, critical]
background:
- given: the cart is empty
steps:
- when: I open the cart and click "Checkout"
- then: checkout is refused or a message explains why

Fields​

FieldRequiredMeaning
nameyesTest name, 1–200 characters.
stepsyes1–60 steps.
descriptionnoUp to 4000 characters.
rolenoThe role whose logged-in session the test starts in. lower_snake_case, for example standard_user.
startnoThe first page, absolute or relative to the environment's base URL.
foldernoFolder for grouping, up to 200 characters.
tagsnoUp to 30 tags. Stored lowercase, spaces become -.
backgroundnoUp to 20 steps that run before steps.
examplesno1–50 rows. The test runs once per row. See examples.
datanoNamed generated values.
dataSeednoA seed that reproduces a run's generated data.
keynoAssigned by Teststream (SLUG-n). Ignored when you create a test.

Steps​

A step has exactly one keyword.

KeywordMeaning
givenA starting condition.
whenAn action.
thenA check.
and, butContinue the kind of the previous step.
useInclude shared steps by name.

Step text is 1–2000 characters. Two extra fields are allowed on given/when/then/and/but steps:

FieldMeaning
dataTest data for the step, such as a value to type or a file name.
optional: trueSkip the step when it does not apply, for example a banner that may not appear.

Shared steps​

- use: new-transaction
with: { amount: "<amount>", note: "Lunch" }
  • The name is kebab-case.
  • with gives the shared steps' parameters. Values are strings, numbers or booleans.
  • A shared step may define defaults for parameters you leave out.

Examples​

steps:
- when: I enter the amount "<amount>"
- then: I see "<shown>"
examples:
- { amount: 5, shown: "$5.00" }
- { amount: 12.5, shown: "$12.50" }

Every <name> used in the steps must be a column in examples, or validation fails.

Generated data​

data:
EMAIL: { faker: internet.email }
LONG_TITLE: { faker: lorem.paragraph, length: 300 }

Names are UPPER_SNAKE_CASE, at most 20 per test. BASE_URL and names starting with EX_ are reserved. Use a value in steps, step data, the description and start as $NAME. It is generated once per run.

GeneratorProducesOptions
person.firstName, person.lastName, person.fullNameA namenone
internet.usernameA usernamenone
internet.emailA synthetic address on example.testnone
company.nameA company namenone
commerce.productNameA product namenone
location.streetAddress, location.city, location.zipCodeAn address partnone
phone.numberA phone numbernone
lorem.wordsWords (3 by default)count (1–100), length
lorem.sentence, lorem.paragraphTextlength
string.uuidA UUIDnone
string.alpha, string.alphanumericLetters, or letters and digits (10 by default)length
number.intAn integer (0–1000 by default)min, max

length is an exact character count from 1 to 2000. min and max are inclusive, from −1,000,000,000 to 1,000,000,000.

Variables and secrets​

$USERNAME and $PASSWORD style variables come from the environment. Never write a secret value in a test.