Agent Wranglers

TST-2Recommended

Keep most tests small and fast

Write many small, fast tests and only a few slow, wide ones. Each kind of test checks what only it can check.

How to do it

Unit tests cover rules and calculations. Integration tests cover how your code talks to a database or another service. Browser tests cover a few whole journeys. When a slow test only checks logic, move that check down to a unit test. The exact shape matters less than the cost of each test. A web app with little logic of its own may follow a trophy shape, with integration tests as the largest group. A set of small services may follow a honeycomb, with most tests at each service's edge. Both are fine. Keep the whole suite within the limits that Keep the suite within a time budget sets.

Examples

Shell example

# Fail on a browser test whose title names no listed journey
grep -rhoP "test\('\K[^']+" tests/e2e | grep -vxFf journeys.txt && { echo "FAIL: browser test outside the journey list"; exit 1; }
time npm test

How to check

Every browser test names a journey from the critical journeys list, and a script fails on any that does not. The full suite stays within its time budget.

Sources

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/testing/test-strategy/test-shape">Agent Wranglers testing playbook</a>. In code you write, add a comment next to it with the same link.