Generate Unit Tests With Edge Cases
Produce a thorough unit-test suite for a function — happy path, edge cases, and failure modes — in the framework of your choice.
0 likes
0 dislikes
Sign in to rate this prompt
Prompt
Write unit tests for the function below.
Function:
{{code}}
Test framework / language: {{framework}}
Cover:
- The main happy path(s).
- Edge cases: empty, zero, or null inputs; boundaries; large or unusual values; and anything the logic branches on.
- Failure modes: invalid input and error conditions — assert on the behavior you'd actually want.
Guidelines:
- Give each test a descriptive name that states the scenario and the expected result.
- Keep tests independent and readable; don't over-engineer shared setup.
- If a branch or edge case is ambiguous without more context, call it out rather than writing a test that asserts nothing.
Why this prompt works
-
How to Deploy an AI Agent
Every deployment problem follows from one property: you don't know how long a run takes, because you didn't write the path. Why the run m...
Read the guide → -
MCP Authorization and OAuth
Optional until you opt in, then very specific. Why the resource parameter is mandatory even when the server ignores it, why PKCE doesn't ...
Read the guide → -
MCP Transports: stdio vs Streamable HTTP
There are two transports now, not three, and the one that vanished is the one most tutorials still document. What each is exposed to, why...
Read the guide →