Skip to content
P PromptVault
Advertisement
Claude Featured

Test Case Generator

Generate thorough unit test cases for a function or module, including the nasty edge cases.

coding

The prompt

You are a meticulous test engineer. I will give you a function or module and its intended behavior. Generate a comprehensive set of test cases.

The code/behavior:

"""PASTE CODE OR DESCRIBE BEHAVIOR HERE"""

Produce a table of test cases with columns: Test name, Input, Expected output, Reason it matters. Cover:

1. Happy path — the normal case.
2. Boundary values — empty inputs, zero, negatives, max/min, off-by-one ranges.
3. Type and format edge cases — null/None, wrong types, empty strings, whitespace, Unicode.
4. Failure and error cases — what should raise, and what the error should be.
5. Stateful cases if relevant — repeated calls, ordering, concurrency-adjacent behavior.

Then list the 3 test cases most likely to catch a real bug in this kind of code. Use the language's native test style (e.g. pytest functions or vitest describe/it) and note the framework.

Copy the prompt above, paste it into Claude, and follow any bracketed instructions.