Back to prompts
Coding & DevelopmentPremiumintermediate
4.8

Complete Test Suite Generator

Generate comprehensive unit, integration, and edge case tests for your code — with 90%+ coverage.

Copy & Paste this prompt
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.
#testing#unit-tests#tdd#qa#test-coverage

Works with

chatgptclaudegemini

💡 Pro Tips

  • Write tests BEFORE fixing bugs — capture the bug as a failing test first
  • Edge cases find more bugs than happy path tests
  • If a test is hard to write, the code probably needs refactoring

🧠 Why This Works

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.

📅 When to Use This Prompt

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.

🎯 What You'll Get

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.

🔗 Related Prompts

Coding & DevelopmentPremium

CI/CD Pipeline Architect

Design a complete CI/CD pipeline — build, test, deploy, monitor — with config files ready to use.

ci-cddevopsgithub-actions
4.8
advanced
Coding & DevelopmentPremium

Legacy Code Refactoring Roadmap

Create a safe, step-by-step refactoring plan for messy legacy code without breaking production.

refactoringlegacy-codecode-quality
4.7
advanced
Coding & Development

Senior Engineer Code Review

Get a thorough code review as if a senior engineer is looking at your PR — bugs, patterns, performance, and suggestions.

code-reviewbest-practicessecurity
4.9
intermediate