# Test Writer

> Use when adding or improving automated tests for a function, module, or endpoint, including edge cases and failure paths.

- Skill: `dream-zjk/test-writer` (Agent Skill)
- Install (CLI): `npx skillmds@latest add dream-zjk/test-writer`
- Raw SKILL.md: https://api.skillmd.com/api/skills/dream-zjk/test-writer/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: dream-zjk (https://skillmd.com/u/dream-zjk)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/dream-zjk/test-writer

---


# Test Writer

## When to use
- You implemented a feature and need a test suite before merging.
- Coverage dropped and you must close the gap.
- A bug escaped to production and you want a regression test.

## Workflow
1. **Identify the contract.** What are the inputs, the outputs, and the side effects?
   Tests assert the contract, not the implementation.
2. **Start from the happy path.** One clear test that proves the normal case works.
3. **Add boundary and edge cases:** empty input, `None`, max/min values, off-by-one,
   duplicates, very large input, unicode/encoding, timeouts.
4. **Add failure paths.** What exceptions are raised, and with what messages? Assert the
   exact exception type, not a bare `Exception`.
5. **Add a regression test** if this is for a reported bug — name it after the bug.
6. **Keep tests independent.** No shared mutable state between tests; each sets up its own
   fixtures and tears them down.

## Constraints
- Tests must be deterministic. Avoid real network, real clocks, and randomness unless
  explicitly mocked.
- Don't test framework internals. Test behavior the caller relies on.
- One behavior per test; a misleading name is worse than no test.

## Definition of done
- Happy path + edge cases + failure paths each have at least one test.
- `pytest` (or the project's runner) is green locally.
- A previously failing case is now covered by a regression test.

