Unit Test Generator prompt for Claude

Draft unit tests for an agreed behavior, including the boundary or error cases that are easiest to miss.

Use the Unit Test Generator prompt

Copy the prompt into Claude and replace any sample inputs with your own.

Prompt
Write tests for [function or module] in [framework]. Cover the main contract, input boundaries, and expected errors. Give cases names that state behavior, keep fixtures small, and call out any requirement the current code leaves ambiguous.
Download Markdown

Choose test inputs from the contract

Provide the expected behavior and framework along with the function. For a parser that accepts whole numbers, supply examples just inside and outside the allowed range. Say what should happen with missing input or whitespace if the contract specifies it.

Check that each assertion would fail if the behavior broke. Small fixtures should make it obvious what the test protects. Run the cases with your normal test command and resolve ambiguous requirements before enshrining one guess as a passing test.

Browse Prompts