Coding
AI Prompt for Edge Case Tests
Uncover hidden edge cases with this AI prompt: adversarial inputs grouped by category, expected behavior for each, and ready-to-run test code.
The prompt
Role: You are an adversarial tester whose job is to break functions with inputs the developer never imagined. Context: Language: [LANGUAGE], framework: [FRAMEWORK]. Function: [FUNCTION_CODE]. Its contract: [CONTRACT]. Already-known tricky inputs: [KNOWN_TRICKY]. Task: 1) Brainstorm edge cases by category: empty/null/undefined, boundaries (0, -1, max), type confusion, unicode/emoji, huge inputs, time/date quirks, locale differences, concurrent calls. 2) For each case: the input, what SHOULD happen per [CONTRACT] (or "undefined — you decide"), and why it is tricky. 3) Write the test code for the 10 most valuable cases. 4) Flag any case where the contract itself is ambiguous — those need a product decision, not just a test. Format: Cases grouped by category, each with input | expected | why-tricky, then the test code, then the ambiguous-contract flags. Constraints: Prioritize cases likely in REAL usage over exotic ones. If the contract is silent on a case, say so instead of inventing the expected behavior.
Variables to fill in
Replace each [variable] in the prompt with your own details:
[LANGUAGE] [FRAMEWORK] [FUNCTION_CODE] [CONTRACT] [KNOWN_TRICKY]
Example input
FUNCTION=parseDate(input) accepting multiple formats, LANGUAGE=JavaScript, FRAMEWORK=Jest, KNOWN_TRICKY=Feb 29, timezone offsets, 'tomorrow'
How to use this prompt
Name the tricky inputs you already know — the AI builds on them instead of repeating them. Specify which edge cases should be handled vs rejected.
Tips for the best results
- Run the generated tests before fixing anything — failing edge tests are a roadmap.
- For ambiguous cases, ask the AI to draft the product question for your team.
- Re-run this prompt after every major refactor; new code has new edges.
Frequently asked questions
Will it find edge cases I wouldn't think of?
It brainstorms adversarial inputs systematically by category — then you pick which ones your function must handle.
What if the expected behavior for an edge case is unclear?
The prompt flags those as contract ambiguities instead of guessing. Take the list to your team — those are product decisions, not test decisions.