Generate Comprehensive Unit Tests for Any Function
Paste your function and get a complete test suite covering happy paths, edge cases, and error scenarios.
Generate comprehensive unit, integration, and edge case tests for your code — with 90%+ coverage.
You are a QA engineer and testing expert. Write a complete test suite for my code. Language: [LANGUAGE] Test framework: [Jest / Pytest / JUnit / Mocha / Vitest / OTHER] Code to test: ``` [PASTE YOUR CODE HERE] ``` Generate: 1. **UNIT TESTS** - Happy path tests (expected inputs → expected outputs) - Edge cases (empty, null, undefined, zero, negative, max values) - Error cases (invalid inputs, missing params, type mismatches) - Boundary conditions 2. **INTEGRATION TESTS** (if applicable) - Test interactions between functions/modules - Database/API mock setup - State management tests 3. **TEST ORGANIZATION** - Group by feature/function using describe blocks - Clear, readable test names (should read like documentation) - Setup and teardown helpers - Shared fixtures and factories 4. **COVERAGE ANALYSIS** - Which lines/branches are covered - Which edge cases might still be missing - Mutation testing suggestions (tests that catch real bugs) 5. **MOCKING STRATEGY** - What to mock and why - Mock implementations - When NOT to mock (test the real thing) Every test should have: Arrange → Act → Assert structure. Every test name should describe the scenario: 'should return empty array when input is null'. Aim for 90%+ coverage without testing implementation details.
High test coverage requires thinking in layers—unit tests for logic, integration tests for connections, and edge cases for resilience. This prompt generates all three systematically, targeting 90%+ coverage with tests that catch real bugs, not just inflate metrics.
Use when building a test suite from scratch for an existing module, when you need to hit specific coverage targets before a release, or when you want comprehensive tests that cover happy paths, error scenarios, boundary values, and integration points.
You'll get a complete test suite organized by test type (unit, integration, edge case) with proper mocking, realistic fixtures, descriptive test names, and coverage analysis showing which branches are tested—ready to run in CI/CD.
Paste your function and get a complete test suite covering happy paths, edge cases, and error scenarios.
Design a complete CI/CD pipeline — build, test, deploy, monitor — with config files ready to use.
Create a safe, step-by-step refactoring plan for messy legacy code without breaking production.
Get a thorough code review as if a senior engineer is looking at your PR — bugs, patterns, performance, and suggestions.
Design a complete error handling system for your app. Custom error classes, proper logging, user-friendly messages, retr…