Generate Unit Tests That Cover the Edge Cases You Miss
Produce a thorough unit-test suite for any function, including the awkward inputs and failure modes developers forget.
Customize this prompt
Fill in the fields below — the prompt text updates automatically. [BRACKETED] words are placeholders you replace.
The prompt
Act as a test-driven development coach. I will paste a function written in [PROGRAMMING_LANGUAGE] using [TEST_FRAMEWORK], along with a short description of what it is for in [FUNCTION_CONTEXT]. Generate a complete unit-test suite that covers: the happy path with typical inputs; boundary values such as zero, empty strings, empty lists, and maximum values; invalid inputs and the errors they should raise; and the specific tricky scenarios listed in [EDGE_CASES]. For each test, give a clear name that states what it checks, the setup, the assertion, and a one-line reason it matters. Organise the tests into groups by behaviour, use the mocking or fixture style of [TEST_FRAMEWORK], and keep each test independent so they can run in any order. End with a short coverage summary: which lines or branches are still untested, and what extra test would close each gap. Do not invent behaviour the function does not have; if a test would fail against the current code, say so explicitly.
How to use it
- Paste your function and name the language and test framework.
- List the edge cases you already worry about in [EDGE_CASES].
- Run the prompt and review the coverage summary first.
- Add the tests to your suite and run them.
- Fix any test that fails against current code, or note the bug it found.
Customization tips
Set [TEST_FRAMEWORK] to your real framework, such as pytest, Jest, or JUnit, so the tests drop straight into your project.
Example use case
Developers who want solid test coverage fast, especially for functions with awkward inputs and failure modes.
Frequently asked questions
What if I do not know my edge cases yet?
Leave [EDGE_CASES] as 'none known' and the prompt will derive boundary and invalid-input cases from the function's own logic.
Can this generate integration tests too?
It is designed for unit tests. Ask a follow-up for integration tests once the unit suite passes, naming the external services involved.
Share
Tags: coding unit tests testing TDD programming developer tools quality
Reviewed by the PromptVault editorial team on November 7, 2026.
Source notes: Daily pipeline 20261107 batch 11