Home › Prompts › Claude › Generate meaningful unit tests
Generate meaningful unit tests
Tests that cover behavior, edge cases and failure modes for a function, in your framework's style.
ClaudeCodingRuleStack original
Written for Claude Sonnet 5.5 · Updated 2026-10-16
Note: Review and test before use. Provided as is, without warranty. See Terms.
Prompt
DownloadWrite tests for the code below using [framework, e.g. Vitest/pytest]. Cover: normal cases, boundaries, invalid input, error paths, and one property-style test if useful. Follow the style of this existing test: <example>[paste a test]</example>. Don't test private implementation details. List any behavior that seems like a bug instead of writing a test that locks it in.
<code>[paste code]</code>Replace everything in [square brackets] with your own details.
Settings & parameters
claude-sonnet-5-5for speed; Opus for complex logic
Variations
- "Write the failing test that reproduces bug [description]."
Tips
- Ask for bug flags; otherwise tests may cement wrong behavior.