Code · August 15, 2026
Get a full unit test suite for your function
Paste a function and get unit tests that cover the normal and edge cases, explained one by one.
This prompt turns any function you paste into a ready-to-run unit test suite, with normal and edge cases covered and explained, so you catch bugs before they hit production.
For: ChatGPTClaude
Full prompt
Act as a senior software engineer specialized in testing. I'll paste a function and your job is
to write a complete unit test suite for it, in the same language and using the testing framework
I specify.
My function:
[PASTE YOUR FULL FUNCTION HERE]
Language: [E.G. JAVASCRIPT, PYTHON, TYPESCRIPT]
Testing framework I use: [E.G. JEST, PYTEST, VITEST]
What this function does in one sentence (give context if it's not obvious): [EXPLAIN WHAT IT SOLVES]
With that, deliver:
1. A unit test suite ready to paste and run, covering:
- The normal cases (expected use, with common valid data).
- The edge cases (empty values, null, zero, negative numbers, empty lists, empty strings,
the max or min allowed, whichever applies to this function).
- At least one case that should fail or throw an error, if the function accounts for it.
2. Right before each test (or group of tests), a one-line comment explaining WHAT case it
covers and WHY it matters (what real bug it would catch before it ships).
3. At the end, a short "Coverage" list of the cases you covered and, if you notice an edge case
the function doesn't handle well, flag it as a separate warning (don't fix it, just tell me).
Rules:
- Don't invent behavior the function doesn't have: if something is unclear, write
[behavior to verify] instead of assuming.
- Use descriptive test names (what's tested and what's expected), not generic ones like "test1".
- Don't add tests for external libraries or code I didn't give you.
Short link: wandabuilds.ai/p/X6uN
Come back tomorrow for another, or see all prompts.