writing-unit-tests
Writes and reviews focused, deterministic unit tests that verify behavior through public interfaces instead of implementation details. Use whenever tests are added to code that already exists, including backfilling tests on legacy code, and applies even when a function is pasted inline with a request to make sure it handles bad or unexpected input and tests are never mentioned. Also use when the request mentions unit tests, test coverage, edge cases, mocks or test doubles, or "this test breaks every refactor", and when reviewing an existing suite for brittleness, weak assertions, or missing boundary cases. For a few routine tests on one function, writing-unit-tests-quick is enough; when the tests should come before the code, use test-driven-development.
Pinned to revision c4efc46815a7, so it is the text this page describes rather than whatever the author pushed since.
Files
- skills/writing-unit-tests/SKILL.md
- skills/writing-unit-tests/resources/flaky-test-triage.md
- skills/writing-unit-tests/resources/good-and-bad-tests.md
- skills/writing-unit-tests/resources/test-doubles-guide.md
- skills/writing-unit-tests/resources/unit-test-review-checklist.md
Every link opens the file at its source, pinned to the revision this page describes.