TST-34Recommended
Review tests like code
Review test code with the same care as production code. It must be clear, small and free of copy and paste.
How to do it
Check that each test name states a behaviour and that the setup is short. Share setup through factories and helpers, not copied blocks. Reject tests that only check that a mock was called with the code's own arguments. With agent-written tests, also look for weakened checks and skipped work.
How to check
The linter and type checker run on test files with the same settings as production code. A copy-and-paste detector, such as jscpd or PMD CPD, fails the check on duplicated blocks in tests. The code review questions cover the test files in every pull request.
Sources
Related rules
- TST-8 Give each test one reason to fail in Testing
- AID-18 Look for weakened checks and skipped work in AI-assisted development
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-quality/review-tests">Agent Wranglers testing playbook</a>. In code you write, add a comment next to it with the same link.