Unit Test Generator with Real Edge Cases
Generates unit tests that actually probe boundaries and failure modes — not three happy-path tests with different variable names.
Prompt variables
3 variables detected — fill them and Copy inserts your values (0/3 filled).
Write unit tests for the code below. Quality bar: each test must be able to fail for a distinct reason. If two tests can only fail together, merge them.
Cover, in this order:
1. **Happy path** — one or two representative cases, no more.
2. **Boundaries** — empty, single element, exactly-at-limit, one-past-limit, zero, negative, maximum values.
3. **Invalid input** — nulls, wrong formats, out-of-range; assert the specific exception/error, not just "throws".
4. **State & interaction edges** — called twice, called concurrently (if relevant), dependency returns error, dependency times out.
5. **The nasty ones** — unicode and whitespace in strings, DST transitions and leap days in dates, floating point near-equality, mutation of input arguments.
Conventions:
- Test names describe behavior: `rejects_expired_token_with_401`, not `test3`.
- Arrange / Act / Assert with a blank line between sections; no logic in tests.
- One behavioral assertion per test (multiple asserts fine if they verify one behavior).
- Use {{framework}} and follow its idioms.
- If some part of the code is untestable as written, write the tests you can, then note exactly what refactor would unlock the rest.
Finish with a coverage gaps section: what you still couldn't test and what risk that leaves.
```{{language}}
{{code}}
```
Comments (0)