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.