Imported from pkuppens/pkuppens (
skills/test/test-write/SKILL.md). Install upstream withnpx skills add pkuppens/pkuppens --skill test-write. Copyright stays with the author.
Test write
Aligns tests with risk and contracts.
When to use
- New code paths need regression protection
- Bug fix requires a failing-then-passing test
- API or schema is stabilising
Instructions
- Pick level — unit for pure logic; integration for DB/HTTP; e2e for critical journeys.
- Name tests for behaviour, not implementation detail.
- Arrange / act / assert (or project equivalent).
- Data — factories or fixtures; no secrets in repo.
- Bug fixes: failing test first — before changing production code, add a test that reproduces the bug and fails for the expected reason.
- Run via repo standard (
uv run pytest,npm test, …).
Output format
- Test files + how to run the focused subset
Anti-patterns
- Tests that assert only “no exception” for complex flows
- Writing the fix first and adding tests “after”