# Edge Case & Test Case Generator

Analyzes a function or feature and generates a comprehensive list of edge cases and corresponding test cases, catching scenarios developers commonly miss.

## Prompt

You are a QA-minded senior engineer known for thinking of edge cases other developers miss.

Language/framework: {{language_framework}}
Code/function to test:
{{code_block}}
Expected normal behavior: {{expected_behavior}}

Do the following:
1. List the standard/happy-path test cases first (2-3 cases covering typical expected use).
2. List edge cases across these categories: boundary values (empty, zero, max/min, single item), invalid/malformed input, unexpected types or null/undefined values, concurrency or timing issues (if relevant), and unusual but valid real-world scenarios that are easy to overlook.
3. For each edge case, state what the code should do (the expected correct behavior) and flag if the current code as written would likely fail that case.
4. Write actual test code for the 5 most important edge cases identified, using an appropriate testing framework for the language ({{testing_framework_if_known}}).

## Best for

Developers writing or reviewing functions who want thorough test coverage without manually brainstorming every edge case, especially before shipping code to production.

## Compatible tools

- Claude
- ChatGPT

## How to use

- Paste the function or code block along with a description of its expected normal behavior.
- Specify your testing framework so generated test code is directly usable.
- Review flagged cases where the current code would likely fail and fix them before considering the code production-ready.
- Add the generated test code to your test suite, adapting variable names and imports to match your project structure.

## Customization tips

- For functions handling user input directly, ask for extra emphasis on malicious or malformed input cases.
- For async functions, explicitly ask for edge cases around timing, race conditions, and promise rejection handling.
- If you only need the edge case list without full test code, say so to get a faster, lighter-weight response.

## Example input

Language: JavaScript. Code: [a function that calculates a discount price given a base price and a discount percentage]. Expected behavior: Returns the discounted price rounded to 2 decimal places. Testing framework: Jest.

## Example output

Happy-path cases like a 20% discount on $100, edge cases including a 0% discount, a 100% discount, a negative price input (flagged as likely to fail since the current code doesn't validate for negative values), a discount percentage over 100 (flagged as producing a negative price incorrectly), and floating-point rounding edge cases, followed by 5 Jest test blocks covering the most critical of these scenarios with assertions.
