Skip to main content
CodingTestingintermediate

Exhaustive Edge-Case Unit & Integration Test Generator

Analyze production functions to discover subtle concurrency, boundary, and null pointer edge cases and write unit tests.

Compatibility & Specs

Compatible AI Models
ClaudeChatGPTGemini
Last UpdatedApr 1, 2026
Customizable Variables3 parameters

How to Use This Prompt

Follow this 3-step workflow to extract high-signal responses from any compatible AI model.

01

1. Tailor the Parameters

Use the interactive customizer above to substitute the bracketed placeholders with your exact context, requirements, and constraints.

02

2. Send to AI Model

Copy the prompt and paste it into Claude, ChatGPT, Gemini, or Copilot. These models follow structured multi-step constraints reliably.

03

3. Review and Iterate

Review the output against the verified benchmark below. Follow up in the conversation to stress-test edge cases or refine tone.

Prompt Variables & Parameters

Reference breakdown of every dynamic variable embedded in this prompt template.

PlaceholderParameter NameTypeStatusDescription & Guidance
[test_framework]Testing Framework & LanguagetextRequiredThe testing library usedDefault: Vitest + TypeScript
[source_code]Source Code to TesttextareaRequiredPaste the function, class, or service to testDefault: export function calculateProratedRefund( billingCycleStart: Date, billingCycleEnd: Date, cancellationDate: Date, monthlyFeeCents: number ): number { const totalCycleMs = billingCycleEnd.getTime() - billingCycleStart.getTime(); const usedMs = cancellationDate.getTime() - billingCycleStart.getTime(); const unusedRatio = Math.max(0, 1 - (usedMs / totalCycleMs)); return Math.round(monthlyFeeCents * unusedRatio); }
[business_constraints]Business Rules / ConstraintstextareaRequiredRules the code must strictly upholdDefault: 1. Refund must never exceed monthlyFeeCents; 2. If canceled after cycleEnd, refund must be 0; 3. If canceled on exact cycleStart, full refund; 4. Gracefully handle invalid dates or cycleEnd <= cycleStart without throwing unhandled exceptions.

Example Execution & Benchmark Output

Sample input arguments and the verified AI response demonstrating expected quality and formatting.

Sample VariablesInputs
[test_framework]
Vitest + TypeScript
[source_code]
export function calculateProratedRefund( billingCycleStart: Date, billingCycleEnd: Date, cancellationDate: Date, monthlyFeeCents: number ): number { const totalCycleMs = billingCycleEnd.getTime() - billingCycleStart.getTime(); const usedMs = cancellationDate.getTime() - billingCycleStart.getTime(); const unusedRatio = Math.max(0, 1 - (usedMs / totalCycleMs)); return Math.round(monthlyFeeCents * unusedRatio); }
[business_constraints]
1. Refund must never exceed monthlyFeeCents; 2. If canceled after cycleEnd, refund must be 0; 3. If canceled on exact cycleStart, full refund; 4. Gracefully handle invalid dates or cycleEnd <= cycleStart without throwing unhandled exceptions.
Expected AI ResponseVerified Result
### 1. Edge-Case Matrix - **Boundary:** Cancellation on exact billingCycleStart millisecond → Expected: 100% refund. - **Boundary:** Cancellation on exact billingCycleEnd millisecond → Expected: 0 refund. - **Temporal Inversion:** billingCycleEnd <= billingCycleStart → Expected: Throws descriptive `InvalidBillingCycleError` rather than returning `NaN` or dividing by zero. - **Future Cancellation:** cancellationDate > billingCycleEnd → Expected: Returns 0, not negative refund. - **Negative / Zero Fee:** monthlyFeeCents <= 0 → Expected: Returns 0. ### 2. Vitest Test Suite Excerpt ```typescript describe('calculateProratedRefund', () => { const FEE = 3000; // $30.00 const START = new Date('2026-06-01T00:00:00Z'); const END = new Date('2026-07-01T00:00:00Z'); it('should return full refund when cancellation occurs exactly at cycle start', () => { const refund = calculateProratedRefund(START, END, START, FEE); expect(refund).toBe(FEE); }); it('should return zero when cancellation occurs after billing cycle end', () => { const afterEnd = new Date('2026-07-05T00:00:00Z'); const refund = calculateProratedRefund(START, END, afterEnd, FEE); expect(refund).toBe(0); }); it('should throw RangeError if billingCycleEnd is prior to billingCycleStart', () => { expect(() => calculateProratedRefund(END, START, START, FEE)) .toThrow('billingCycleEnd must be after billingCycleStart'); }); }); ```

Best Use Cases

Scenarios and roles where this prompt produces maximum leverage.

Engineers writing mission-critical billing, financial, or authentication logic
Developers aiming for 100% meaningful mutation test coverage before pull request review
Refactoring legacy code without existing automated regression tests

Tips for Best Results

Techniques to elevate response fidelity

  • •Provide rich background context rather than one-sentence inputs to receive deep, non-generic responses.
  • •Engage in multi-turn conversation: use the initial output as a baseline, then ask the AI to sharpen specific sections.
  • •Prompt the model to highlight any hidden assumptions or missing trade-offs in its recommendations.

Common Mistakes to Avoid

Frequent failure modes and anti-patterns

  • •Giving minimal context and expecting nuanced, expert-level strategic output.
  • •Not validating factual references, citations, or statistical claims with verified primary sources.
  • •Skipping the customization step and pasting raw bracketed template variables into the AI chat.

Part of Curated Collections

This prompt is sequenced as part of these goal-oriented workflows

View all collections

Related AI Prompts

Complementary workflows in Coding

View all Coding prompts
Codingadvanced

Principal Code Reviewer & Architecture Auditor

Conduct rigorous architectural code reviews identifying memory leaks, race conditions, and typing holes.

claudechatgptcopilot
#code-review#clean-code#architecture
Codingadvanced

Pragmatic REST & GraphQL API Contract Architect

Design robust, backwards-compatible API contracts with clean error schemas, pagination, and idempotency keys.

claudechatgptgemini
#api-design#rest-api#graphql
Codingintermediate

Legacy Codebase Refactoring & Technical Debt Reducer

Systematically deconstruct tightly coupled spaghetti code into isolated, testable pure functions without breaking behavior.

claudechatgptgemini
#refactoring#technical-debt#code-smells

Related Engineering Guides

Deep-dive playbooks and system prompt methodologies for Coding

View all guides