Coding TEXT

Test Case Generator for Unit and Integration Tests

April 1, 2026 Optimized for: general Writing test suites for new features, improving test coverage, establishing testing patterns

Prompt

You are a senior QA engineer and testing expert. Generate comprehensive test cases for the given code or feature. Cover unit tests, integration tests, and edge cases.

**Code/Feature to Test:**
[PASTE CODE OR DESCRIBE FEATURE]

**Tech Stack:** [e.g., Jest/Vitest + React Testing Library, Pytest, Go testing, JUnit]
**Test Runner:** [e.g., Jest, Vitest, Pytest, Go test]

**Generate tests following this structure:**

1. **Unit Tests** (isolated, fast, no external dependencies):
   - Happy path: Test normal expected behavior with valid inputs
   - Edge cases: Empty strings, null/undefined, zero, negative numbers, max values
   - Boundary conditions: Off-by-one errors, array bounds, string length limits
   - Type variations: Different input types that should be handled
   - Error cases: Invalid inputs that should throw specific errors

2. **Integration Tests** (test component interactions):
   - API calls: Mock HTTP requests, test loading/error/success states
   - Database operations: Test CRUD with test database or in-memory DB
   - Component integration: Test parent-child component communication
   - Service layer: Test business logic with mocked dependencies

3. **Test Organization:**
   - Use describe blocks to group related tests
   - Use clear test names: 'should [expected behavior] when [condition]'
   - Setup and teardown with beforeEach/afterEach
   - Shared fixtures and test data factories
   - Test isolation: Each test must be independent

4. **Mocking Strategy:**
   - Identify all external dependencies to mock
   - Create typed mock factories
   - Verify mock calls (called with correct arguments, correct number of times)
   - Reset mocks between tests

5. **Coverage Goals:**
   - Line coverage: > 90%
   - Branch coverage: > 85%
   - Identify untestable code and suggest refactoring

**Output**: Complete test file(s) ready to run, with comments explaining the reasoning behind each test case.

Tags

Generates comprehensive unit and integration test suites with edge cases, mocking strategies, and clear test organization.

Share This Prompt

Related Prompts

Have a Great Prompt to Share?

Submit your own AI prompts to the community. The best ones get featured on TokenCalculator - and credited to you.

Submit a Prompt

Ratings & Feedback

0.0 / 5 · 0 votes

Comments