← Prompt libraryWrite Tests
Skill · Testing · #tests #tdd
write-tests
Write thorough, readable tests for a unit of code. Use when you need solid tests for a specific unit of code.
Write tests
Cover behavior, not implementation details.
Steps
- Identify the unit's contract: inputs, outputs, and side effects.
- Enumerate cases: happy path, boundaries, invalid input, error handling, and any state-dependent behavior.
- Name each test for the scenario it checks (e.g. "returns 0 for an empty list").
- Arrange–Act–Assert; one logical assertion per test where practical.
- Mock only true external dependencies (network, clock, filesystem) — never the code under test.
Output
A complete test file in the project's framework, with the riskiest cases first.
This is one of dozens of free prompts in the AIStorageDepot library. Sign up free to save them, version them, and pull them straight into Claude, Cursor, or VS Code over MCP.