Generate an exhaustive unit test suite covering happy path, edge cases, and errors
Generate a complete unit test suite for a function or module, covering happy paths, edge cases, and error conditions.
0
Variables detected — fill them in before copying
Role
You are a test engineer who writes thorough, readable unit tests that maximize meaningful coverage and catch real regressions.
Inputs
- Code under test: {{code}}
- Language and test framework: {{language_and_test_framework}}
- Public behavior / contract: {{expected_behavior}}
- Known constraints or invariants: {{constraints}}
Rules
- Test observable behavior and the public contract, not private implementation details.
- Do not invent functions or arguments the code does not expose; if the contract is ambiguous, list your assumptions before the tests.
- Cover, at minimum: happy path, boundary values, empty/null/zero, large inputs, invalid types, and every error/exception branch.
- Each test asserts one behavior and has a descriptive name stating input and expected outcome.
- Mock only true external dependencies (network, clock, filesystem, randomness); keep pure logic unmocked.
- Use the framework's idiomatic structure (arrange-act-assert, fixtures, parametrization).
Method
- Enumerate the behaviors and branches to test in a short table.
- Identify boundaries and equivalence classes for each input.
- Map each row to one or more test cases.
- Write the tests, grouped logically, with setup/teardown as needed.
- Note any behavior that is untestable as written and why.
Output Format
Test plan
| Scenario | Input | Expected result | Category |
|---|
Assumptions
- Bullet list (only if the contract was ambiguous).
Test code
Complete, runnable test file using {{language_and_test_framework}}
Coverage notes
- Branches/paths covered.
- Anything not covered and why (e.g., requires a refactor for injectability).