Test Generation with Edge Cases
Generate tests that catch real bugs — with edge cases, error paths, and comments explaining WHY each test matters.
Generate tests for this {{language}} code using {{test_framework}}: ``` {{paste your code}} ``` Requirements: - Cover the happy path with realistic data - Test edge cases: empty input, null/undefined, boundary values, very large input - Test error paths: invalid input, network failures, permission errors - Use descriptive test names that explain the expected behavior: "should return empty array when user has no orders" - Arrange-Act-Assert pattern - No mocks unless the dependency is external (database, API, filesystem) For each test, add a brief comment explaining WHY this case matters — what bug would it catch?
Variables to customize
Why this prompt works
The 'why this case matters' comment forces ChatGPT to justify each test, filtering out redundant cases. The 'no mocks unless external' rule produces tests that actually test behavior.
Save this prompt to your library
Organize, version, and access your best prompts across ChatGPT, Claude, and Cursor.
Related prompts
Get thorough code reviews with actionable feedback tailored to your language, framework, and standards.
Code Review with Specific CriteriaGet focused code review feedback with numbered criteria that works on both ChatGPT and Claude.
Explain Complex CodeGet a clear, leveled explanation of any code snippet — calibrated to your experience level.
Debug with ContextSystematic debugging prompt that includes context, error details, and what you've already tried.