testingClaude

Edge Case Generation Prompt (Claude)

Developers typically test the happy path and one or two obvious error cases. Edge case generation is where AI adds the most value — it systematically enumerates categories like encoding attacks, timezone boundary conditions, and concurrency issues that developers routinely miss. Requesting 30-50 cases forces the model to be exhaustive rather than stopping at the obvious five. This variant is formatted for Claude: Optimised for Claude 3.5 Sonnet and Claude 3 Opus. Uses XML tags for structured input and output.

Prompt Template
<role>You are an expert AI assistant with deep knowledge in this domain.</role>

<task>
You are a senior QA engineer specialising in boundary value analysis and equivalence partitioning.

Generate a comprehensive list of edge cases and boundary conditions for:

{{subject_description}}

Input specification:
{{input_spec}}

Business rules:
{{business_rules}}

For each edge case, provide:
- **Category**: (boundary | null/empty | overflow | encoding | concurrency | timing | injection | business rule)
- **Input**: the specific test input
- **Expected behaviour**: what should happen (pass, fail with specific error, or undefined behaviour to document)
- **Risk level**: High / Medium / Low
- **Why it matters**: one sentence on the real-world consequence if this case is not handled

Group the cases by category. Target 30-50 cases total.
</task>

<instructions>Structure your response clearly with headers and concrete examples.</instructions>

Variables

{{subject_description}}What you are generating edge cases for, e.g., "a function that takes a date range", "a user registration API endpoint"
{{input_spec}}The valid input range and types, e.g., "accepts two ISO 8601 dates, start must be before end, max range 365 days"
{{business_rules}}Domain-specific rules that constrain valid inputs and outputs

Example

Input
subject_description: A payment processing function that charges a credit card
input_spec: amount (positive decimal, max $10,000), currency (ISO 4217, 3 chars), card_token (string)
business_rules: Minimum charge is $0.50. Duplicate charges (same token + amount within 60 seconds) should be rejected.
Output
**Boundary cases:**
- amount=0.50: minimum valid amount — should succeed
- amount=0.49: below minimum — should reject with "Amount below minimum"
- amount=10000.00: maximum valid amount — should succeed
- amount=10000.01: above maximum — should reject
- amount=0: zero charge — should reject
- amount=-1: negative amount — should reject

**Null/Empty cases:**
- card_token=null: should return 400 "card_token required"
- currency="": empty string — should return 400 "invalid currency"

**Timing/Concurrency:**
- Same request sent twice within 60 seconds: second should return 409 "Duplicate charge detected"

Related Tools

FAQ

How do I use these edge cases with the unit test generation prompt?
Copy the generated edge cases into the unit test generation prompt's "contract" field. The model will generate a test for each case using your specified testing framework.
Can I generate edge cases for UI components?
Yes. Set the subject to "a date picker component" and the input spec to the valid date range and format. The AI will generate cases covering invalid date formats, DST transitions, and accessibility keyboard interactions.
Are 30-50 edge cases too many to implement?
Use the risk level field to prioritise. Implement all High cases immediately. Medium cases can be automated incrementally. Low cases are documented as known limitations and revisited if a related bug is reported.

Related Prompts