Recorded examples
What the captures recorded from real calls and real events, and the tests that replay it.
A hand-written example is a guess about what a neighbour says. A recording asks the real one, keeps the transcript in a journal (capture/, never committed), then a merge writes the examples the tests read (contracts/, committed, reviewed in a diff). The tests then run against testcontainers neighbours fed with those examples: Microcks replays the partner's answers, and the events of the code are compared with the recorded ones.
Prism or Microcks? Not rivals, two jobs. The contract mocks (Prism, the 🎠links of API docs) answer any contract with the same example, for anyone trying an API by hand. Microcks serves the recorded examples of this page to the tests, the answer picked by request (ada gets ada's balance, an unknown account its 404).
This page only reads. To record again, run the commands of each card in a terminal, then reload.
Bank Partner answers (HTTP) http
What the third-party bank really answers for the usernames of the story, so the tests replay real answers instead of guessed ones.
- Recorded from
- the fake Bank Partner on http://localhost:8090, GET /balance
- Journal
- capture/journal.json
- Examples
- contracts/bank-partner-examples.yaml
- Replayed by
- tests/integration/test_hello_balance_microcks.py, tests/integration/test_hello_page_browser.py
- Record again
mise run partner:upthenmise run capture:examplesthenmise run capture:mergethengit diff contracts/
Journal, 0 entries
| Story | Request | Answer | |
|---|---|---|---|
| No journal here: run the commands above. The committed examples below still drive the tests. | |||
Examples the tests replay
| Example | Origin | Content |
|---|---|---|
| ada | captured | 200 {"username": "ada", "balance_cents": 125075, "currency": "EUR"} |
| grace | captured | 200 {"username": "grace", "balance_cents": 980040, "currency": "EUR"} |
| unknown-account | written by hand | 404 {"detail": "No account for this username"} |
Order workflow events (RabbitMQ) events
What our own services really publish on the broker when an order is placed, so a test can check the code still sends the same events in the same order, with the same fields.
- Recorded from
- the broker of mise run up, through its firehose (amq.rabbitmq.trace)
- Journal
- capture/events-journal.json
- Examples
- contracts/order-workflow-recorded.yaml
- Replayed by
- tests/integration/test_orders_rabbitmq.py
- Record again
mise run upthenmise run capture:eventsthenmise run capture:events-mergethengit diff contracts/
Journal, 0 entries
| Story | After | Order placed | Event published |
|---|---|---|---|
| No journal here: run the commands above. The committed examples below still drive the tests. | |||
Examples the tests replay
| Example | Origin | Content |
|---|---|---|
| paid-order | recorded | reserve_stock then issue_invoice then capture_payment |
| out-of-stock-order | recorded | reserve_stock |