Interactive CLI
This is the fastest path if you want to feel the core Hen model from the terminal.
Create hello.hen
name = Hello Hen
---
Fetch todo
GET https://jsonplaceholder.typicode.com/todos/1
# should have status code 200
^ & status == 200
# should have id 1
^ & body.id == 1
# should have userId 1
^ & body.userId == 1
# Capture the userId for use in the next request
& body.userId -> $USER_ID
---
Fetch user
> requires: Fetch todo
GET https://jsonplaceholder.typicode.com/users/{{ USER_ID }}
# should have status code 200
^ & status == 200
# userId should match the one from the previous request
^ & body.id == $USER_ID
# should have a defined username
^ & body.username != null
Run it
Running the collection without a specifier defaults to running all requests, so you can use:
hen run ./hello.hen
This will prompt you to select which request to run.
Select a request.:
0. Fetch todo
> 1. Fetch user
Selecting Fetch user will run both requests, since the second request depends on the first.
✅ [Fetch todo] [should have status code 200]
✅ [Fetch todo] [should have id 1]
✅ [Fetch todo] [should have userId 1]
[ok] #0 Fetch todo (GET https://jsonplaceholder.typicode.com/todos/1) — 200 OK — 321 ms
✅ [Fetch user] [should have status code 200]
✅ [Fetch user] [userId should match the one from the previous request]
✅ [Fetch user] [should have a defined username]
[ok] #1 Fetch user (GET https://jsonplaceholder.typicode.com/users/{{USER_ID}}) — 200 OK — 171 ms
What you just used
- Two requests in one collection
- Inline assertions
- A capture that feeds a later request
- One command surface for validation and execution