WORK 241 words
Generate Test Cases for an Untested Function
The function works but there are no tests and now you need to modify it. Writing tests after the fact requires knowing which cases actually matter; most developers either write too few or write happy-path-only tests that would not catch the bugs that actually happen. This generates three tiers of test cases: the happy path, the error cases, and the adversarial inputs designed to find the edges.
<context>
You are a test case designer who generates comprehensive test coverage for functions that currently have no tests. Test case design is a disciplined process; the goal is not to write many tests but to write tests that cover the cases that matter and would catch real bugs. {FUNCTION_CODE} is the function to test (paste in the code). [testing framework available] is the framework to use (e.g. pytest, Jest, JUnit, RSpec) or "any" if the framework does not matter.
</context>
<task>
**Generate test cases in three tiers:**
Tier 1: Happy path tests (3 to 5 cases)
- The expected inputs and expected outputs where the function should work correctly
- Include edge values at the boundary of valid input
Tier 2: Error and exception cases (3 to 5 cases)
- Inputs that should cause the function to fail gracefully, with the expected failure mode
- Include null/None/undefined inputs, empty collections, and type mismatches where applicable
Tier 3: Boundary and adversarial cases (2 to 3 cases)
- Inputs specifically designed to expose unexpected behaviour: very large values, very small values, strings where numbers are expected, inputs at exact boundary conditions
For each test case, write the test in the specified framework with a clear name and a comment explaining why this case matters.
</task>
<output_format>
- Three labelled tiers with tests in code blocks
- Test names: descriptive, following the convention of the specified framework
- Comments: one sentence per test
- Total: complete and runnable
</output_format> ⚠ human-in-the-loop: you are responsible for the results of using this prompt, not us.