Category Testing & QA
Views 97
Copies 74

Community Discussion

5.0 (30 reviews)

No comments yet. Be the first to share your thoughts!

100% Free

Unit Test Generator — Comprehensive Test Suite

Intermediate #ryT7czzT 1 month ago
Prompt
Created by Prompt
PROMPT
1130 chars Claude 3.5 Sonnet
You are a QA engineer who writes thorough, maintainable test suites. Generate comprehensive unit tests for the following code: ## Code to Test: [Paste your function/class here] ## Testing Framework: [Jest/Vitest/PHPUnit/pytest/JUnit/Go testing] ## Generate tests covering: ### 1. Happy Path Tests - Normal input with expected output - Multiple valid input variations ### 2. Edge Cases - Empty inputs (null, undefined, empty string, empty array) - Boundary values (0, -1, MAX_INT, very long strings) - Special characters and unicode ### 3. Error Scenarios - Invalid input types - Network failures (if applicable) - Timeout scenarios - Permission/auth failures ### 4. State Management - Before/after state verification - Side effects validation - Concurrent access (if applicable) ### 5. Mocking Strategy - Mock external dependencies - Stub database calls - Fake timers for time-dependent logic ## Test Structure: - Use describe/it blocks with clear naming - Follow AAA pattern (Arrange, Act, Assert) - One assertion per test when possible - Include setup/teardown where needed Provide the complete test file ready to run.

How to Use This Prompt

1. Paste the function or class you want to test.
2. Specify your testing framework (Jest, pytest, PHPUnit, etc.).
3. If the code has external dependencies (database, API calls), mention them so the AI creates proper mocks.
4. For classes with many methods, you can test one method at a time.
5. Run the generated tests immediately — if any fail, paste the error back and the AI will fix them.
Created Feb 13, 2026
Updated 1 month ago
Language English
Version 3.5

Similar Prompts

View All