Coding & Debugging Prompts

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.

FreeClaudeChatGPT
Best for

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

Suitable LLM groups
FrontierReasoning
Download Prompt.md
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}}).

How to use

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

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.

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.

Tags

#testing#edge-cases#unit-tests#qa#debugging

FAQ

What is this prompt for?
It analyzes a function and generates a comprehensive list of edge cases across boundary values, invalid input, and unusual real-world scenarios, then writes actual test code for the most critical ones.
How should I customize it?
Specify your language, testing framework, and the function's expected normal behavior clearly, since edge case relevance depends on understanding what correct behavior actually looks like.
Are there any limitations?
Generated edge cases are based on the code and description provided; domain-specific edge cases tied to business rules not mentioned in the prompt may need to be added manually.
How is it different from a basic prompt?
Instead of a generic 'write tests for this' request, it systematically categorizes edge cases by type, flags which ones the current code would likely fail, and produces runnable test code for the highest-priority cases rather than just a list.
Free

Code Review Simulator

Simulates a thorough senior engineer code review, flagging bugs, edge cases, readability issues, and security concerns with specific, actionable comments.

ClaudeChatGPT
#code-review#debugging#software-engineering
Free

Legacy Code Explainer & Refactor Planner

Explains what an unfamiliar or legacy piece of code actually does, then proposes a safe, incremental refactor plan instead of a risky full rewrite.

ClaudeChatGPT
#legacy-code#refactoring#code-review
Free

Root Cause Bug Investigator

Guides a systematic investigation of a bug from symptom to root cause, avoiding quick patches that mask the real problem, and produces a targeted fix.

ClaudeChatGPT
#debugging#root-cause-analysis#bug-fixing

Related Skills

Testing & Quality ChecksFree

QA Test Case Generator

Generates a structured set of test cases — happy path, edge cases, and negative tests — from a feature description or user story.

ClaudeChatGPTCursor
#qa#test-cases#software-testing
Testing & Quality ChecksFree

Test Framework Auto-Detector & Generator

Detects which test framework a project already uses (Jest, Vitest, Pytest, Go testing, and more) and writes new tests in that project's existing style, not a generic template.

ClaudeClaude CodeCursor
#testing#unit tests#jest
Code ImprovementFree

Code Review & Refactor Assistant

Reviews a pasted code snippet for bugs, readability, and performance issues, then delivers a prioritized refactor with explanations for each change.

ClaudeChatGPTCursor
#code review#refactoring#software engineering

Related Articles

Article · Testing & Quality Checks

How to Test AI-Generated Code Before You Trust It

Learn how to review and test AI-generated code before using it in production, including functionality, security, edge cases, permissions, and regression checks.

Jul 5, 20268 min read
Read How to Test AI-Generated Code Before You Trust It