Test plans
A plan runs several requests in order and checks what comes back between them. Reach for one when the thing worth testing is the sequence rather than a single call: list the posts, take the first id, read that post, confirm it is the one you asked for.
A plan is written in a .stamp file, above the file's first request. The file below is whole. Save it as posts.stamp and it runs as it stands.
plan FirstPost {
step "List the posts" {
run listPosts
expect status == 200
set postId = body[0].id
}
step "Read the first one" {
run getPost with postId = postId
expect body.id == postId
expect body.title != null
}
}
### List posts
GET https://jsonplaceholder.typicode.com/posts?_limit=5
### Get post
@postId = 1
GET https://jsonplaceholder.typicode.com/posts/{{postId}}
Read from the top:
plan FirstPost | Names the plan. That name is what you run, and what a report calls the result. |
step "List the posts" | A titled group of statements. Steps are what reports list, and what a retry re-runs as a whole. |
run listPosts | Sends a request by name. listPosts is the title ### List posts turned into an identifier. |
expect status == 200 | A check against the response that came back. status, body, headers, time, size and url are all in reach, and a message can follow a comma. |
A plan says expect where a request's > line says assert. They are the same check: a step takes assert too, and the word is expect here because a plan reads as a list of expectations. | |
set postId = body[0].id | Keeps a value for the rest of the run, so a later step can use it. |
run getPost with postId = postId | with hands values to the request. They win over the @postId = 1 the request carries, which is there so the request still works on its own. |
stamp test takes a file, or a folder and every plan in it.
stamp test posts.stamp
▶ FirstPost posts.stamp
✓ run 170 ms
✓ 1 iteration, 2 requests, 3 checks, 170 ms
✓ all 1 plan passed
The run reports one iteration, because nothing has asked the plan to run more than once, and three checks, one per expect, counted apart from the two requests it sent.
Now suppose the second step also asked expect body.userId == 99. A check that does not hold prints the line and the value found instead, marks its iteration with a cross, and the command exits with 1.
stamp test posts.stamp
▶ FirstPost posts.stamp
✗ run 91 ms
expect body.userId == 99 (body.userId is 1)
✗ 1 iteration, 2 requests, 3 checks, 92 ms
✗ 1 of 1 plan failed
That is a working plan, and for many files it is the whole of it. What follows is for plans that have to run more than once.
Once per environment, once per row
matrix repeats the plan for every combination of dimension values. a|b lists the values to use, * means every value the dimension has, and the chosen value is a variable inside the plan, so a step can read env. A matrix can only name dimensions the workspace declares, so this needs an environment.stamp beside the file:
# environment.stamp
dimension env = test, staging
dimension region = latam, mena, apac, dach
Then the plan above, cut to one step, with that line added:
plan FirstPost {
matrix env = test|staging, region = *
step "List the posts" {
run listPosts
expect status == 200
}
}
stamp test posts.stamp
▶ FirstPost posts.stamp
✓ env=test, region=latam 63 ms
✓ env=test, region=mena 23 ms
✓ env=test, region=apac 25 ms
✓ env=test, region=dach 22 ms
✓ env=staging, region=latam 21 ms
✓ env=staging, region=mena 23 ms
✓ env=staging, region=apac 22 ms
✓ env=staging, region=dach 23 ms
✓ 8 iterations, 8 requests, 8 checks, 210 ms
✓ all 1 plan passed
Every iteration has its own session, so a token one iteration logged in with is never handed to another.
data does the same for the rows of a file: a CSV with a header row, or a JSON array of objects. The columns arrive as variables.
# fixtures/carts.csv
cartId,currency
1,EUR
2,USD
5,GBP
plan EveryCart {
data ./fixtures/carts.csv
step "The cart is the one the row names" {
run getCart with cartId = cartId
expect status == 200
expect body.id == cartId
}
}
### Get cart
@cartId = 1
GET https://dummyjson.com/carts/{{cartId}}
stamp test carts.stamp
▶ EveryCart carts.stamp
✓ row 1 169 ms
✓ row 2 63 ms
✓ row 3 63 ms
✓ 3 iterations, 3 requests, 6 checks, 298 ms
✓ all 1 plan passed
The two multiply. Two environments and three rows are six iterations, labelled env=test, row 2 and so on.
Signing in once, and clearing up after
setup runs before the steps and teardown after them, once per iteration, and the teardown runs whether the steps passed or not. Anything the setup stored with set is in the session the steps start from.
plan ProfileForEveryGroup {
matrix userGroup = *
setup { run logIn }
step "The profile is the account that signed in" {
run currentUser
expect body.username == username
}
teardown { run endSession }
}
That is a whole plan but not a whole file: the three requests it names have to exist somewhere in the same workspace. The userGroup dimension decides which account logIn uses, so one plan covers the admin, the member and the guest.
Flakiness, speed and patience
Three settings, for three different problems.
retry 2 every 500ms | A step that fails is run again from its first line, up to twice more. This is why statements are grouped into steps: the retry replays the whole step, not one assertion. |
parallel 4 | Four iterations at a time. Eight combinations then finish in roughly a quarter of the time, and print in the order they finish rather than in matrix order. |
timeout 2m | An iteration still going after two minutes is abandoned, and reported as plan timed out rather than as a check that did not hold. |
Retries hide a real problem as readily as they absorb a flaky one. Reach for them when the network is the thing you do not trust, not when the API is.
Loops and conditions
for each walks a list and repeat runs a block a fixed number of times; index counts from 0 in both. if and else let one plan behave differently per environment, which is better than keeping two plans that drift apart.
for each quantity in [1, 3] {
step "Order that many" {
run placeOrder with quantity = quantity
expect status == 201
}
}
if env == "prod" {
step "Prices carry tax" {
run basket
expect body.tax > 0
}
} else {
step "Anywhere else, put the basket back" {
run emptyBasket
}
}
Those are statements from the middle of a plan, so they belong inside a plan { } block. There is no statement separator: one statement to a line.
Everything a plan can hold
The settings go at the top of the block, in any order.
matrix name = a|b, other = * | One iteration per combination of dimension values |
data ./file.csv | One iteration per row of a CSV or a JSON array |
parallel 4 | How many iterations run at once |
retry 2 every 500ms | Re-runs a failing step |
timeout 2m | Gives up on an iteration that takes longer |
tags smoke, auth | What --tags selects on |
The statements go below them.
run name, run name with a = expr | Sends a request, with extra variables |
expect condition, expect condition, "message" | Checks the last response |
set name = value, let name = value | A value for the rest of the iteration |
print value, wait 500ms | A line of output, and a pause |
step "title" { … } | Groups statements, and is the unit a retry replays |
setup { … }, teardown { … } | Before and after the steps of each iteration |
repeat 3 { … }, for each x in list { … } | Loops; index counts from 0 |
if condition { … } else { … } | A branch |
concurrently 5 { … } | Actors at the same instant, for race conditions |
stamp test . # every plan in the workspace
stamp test . FirstPost # one plan by name
stamp test . --tags smoke # only the plans carrying a tag
stamp test . env=staging # pick the dimension values yourself
stamp test . --junit reports/junit.xml # for a build server
stamp test . --html report.html # one file to read, and to parse
In the app
A plan is text, and there is no New Test Plan to click: it is written above the requests in a .stamp file. Open the file the requests live in, switch the picker from Form to Source, and write the plan { } block at the top of it. Save, and the plan appears under Test Plans in the sidebar, which is where everything below starts.
- Pick the plan under Test Plans in the sidebar. Before it has run you get its setup, its steps and its teardown as an outline, under a line saying what it will do: Runs once with the selected dimensions, or the axes it runs for, the file of rows, how many iterations at a time, how often a failing step is retried.
- The selector in the header says which value each dimension is on. Change any of them there, then press ⌘↩ for Run Plan. ⌘. stops it.
- While it runs, a line counts the iterations finished out of the total, and each one joins the list below as it lands with its label and its time.
- When it is done the iterations are listed down the left, each saying how many requests it sent or how many failures it had. Select one and its events are the tree on the right: the steps, the requests under them with their method and status, and every
expectwith a tick or a cross. - Select a request in that tree and the exchange it sent and received opens underneath. Until you select one, that half holds Response Times: a row per request, slowest first, each on a bar scaled to the slowest so the one worth looking at is the one you see. A plan that ran once shows one time per request; one that repeated shows the fastest, the average and the 95th, with the bar covering the spread. Once the plan has run more than once, Recent Runs appears beside it with a bar per run and the share that passed.
- Export writes the run as an HTML, JUnit XML or JSON file. Earlier Runs in the toolbar opens a previous one again, and Results and Source switch between this and the text of the plan.
The command prints the iterations and counts them. The window keeps them, so an iteration that failed is two clicks from the request that failed it and the bytes that came back, and the timings sit beside the checks, which is where a plan that passed slowly becomes visible.


Next: Load tests for the same scenario under many users, Race conditions for requests that have to arrive together, and Running in CI for the exit codes a pipeline reads.