Skip to main content
VePrompts
claude-sonnet-4 Coding & Development

While optimized for claude-sonnet-4, this prompt is compatible with most major AI models.

Write Unit Tests

Generate comprehensive unit tests covering happy path, edge cases, and error conditions.

Share

Prompt Health: 100%

Length
Structure
Variables
Est. 217 tokens
# Write Unit Tests **Best model:** Claude 4 Sonnet **Category:** Coding & Development **Tags:** testing, TDD, quality assurance, automation ## Description Generate comprehensive unit tests covering happy path, edge cases, and error conditions. ## Prompt Write unit tests for this function/module. Requirements: 1. HAPPY PATH: 2-3 tests for normal operation. 2. EDGE CASES: Empty inputs, null/undefined, maximum values, boundary conditions. 3. ERROR CASES: Invalid inputs, exceptions, failure modes. 4. MOCKING: Mock external dependencies (API calls, database, file system). 5. COVERAGE: Aim for 80%+ line coverage. Use [TESTING FRAMEWORK - e.g., Jest, pytest, Vitest]. Include setup/teardown if needed. Add descriptive test names that explain what's being tested. One assertion per test where possible. CODE TO TEST: [CODE] LANGUAGE/FRAMEWORK: [LANGUAGE]

Private Notes

Insert Into Your AI

Edit the prompt above then feed it directly to your favorite AI model

Clicking opens the AI in a new tab. Content is also copied to clipboard for backup.

Explore Related Resources