Flaky and slow tests
A test that fails at random teaches people to ignore red builds. Find flaky tests early, quarantine them with an owner, and keep the suite fast.
- Recommended 6
Recommended
Find hidden order dependencies
TST-27Run tests in a random order, so tests that depend on each other fail early.
Quarantine flaky tests with an owner
TST-28Move a test that fails at random out of the blocking suite at once. Give it an owner and a deadline, then fix or delete it.
Find flaky tests before they merge
TST-29Run new and changed tests many times in a row before merging, to catch flakiness while the change is fresh.
Keep the suite within a time budget
TST-30Set a time limit for the whole suite and for each kind of test. Examples are 30 seconds for unit tests and ten minutes for the whole suite. Treat going over it as a failure.
Run the tests a change affects on every pull request
TST-56On a pull request, run the tests that cover the changed files. Run the whole suite on every merge to the main branch and before every deploy.
Give every test its own time limit
TST-59Set a time limit on every single test, such as 5 seconds for unit tests and 60 seconds for browser tests. A test that runs past it fails with its name in the report.
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/flaky-and-slow-tests">Agent Wranglers testing playbook</a>. In code you write, add a comment next to it with the same link.