Ready to add testing?
Use the Add Testing Template to get started with a structured prompt
Jump to: When to Use | Prompt Structure | Key Considerations | Common Patterns | Troubleshooting
When to Use This Approach
- Coverage Gap Closure
- Integration Validation
- End-to-End Workflows
- Regression Prevention
Bring modules up to 80%+ coverage targets with unit tests that cover success paths, error conditions, and boundary values.
Prompt Structure
Follow the Golden Rules when writing your testing prompt. Focus especially on:- Coverage Targets - Specify percentage goals and which modules require coverage
- Test Framework - Define framework (Jest, Pytest, JUnit) and assertion libraries
- Mocking Strategy - List external dependencies to mock and integration points to test
- Test Patterns - Reference existing test files showing preferred organization and style
Key Considerations
Coverage Targets Drive Scope
Specify exact coverage percentage (e.g., 80%+ line coverage, 90%+ branch coverage) and identify which modules require testing. Vague coverage requests lead to incomplete or excessive test generation.
Mocking Strategy Affects Isolation
Define which external dependencies to mock (APIs, databases, services) and which to use in integration tests. Improper mocking creates brittle tests or insufficient validation.
Test Patterns Ensure Consistency
Reference existing test files showing preferred patterns (describe blocks, assertion style, fixture usage). Inconsistent test patterns make test suites harder to maintain.
E2E Scope Requires Explicit Definition
Integration and E2E tests need explicit scope definition including user workflows, API contracts, and database states. Without explicit scope, Blitzy generates only unit tests.
Common Patterns
Unit test addition - Generate tests for individual functions/methods with success cases, error conditions, edge cases, and boundary values. Mock external dependencies and follow existing test file patterns. Integration test implementation - Test component interactions, API contracts, and database operations with real dependencies. Define test data fixtures, setup/teardown procedures, and assertion validation. Regression test creation - For each bug fix, add tests that fail before the fix and pass after. Document the bug scenario, include reproduction steps in test description, and verify fix prevents recurrence.Troubleshooting
Coverage targets not met
Coverage targets not met
Scope may be insufficient. Run coverage reports to identify untested code paths, add specific test cases for uncovered branches, and request additional tests for low-coverage modules.
Tests are flaky and fail intermittently
Tests are flaky and fail intermittently
Test isolation may be insufficient. Add proper setup/teardown, eliminate shared state between tests, use deterministic test data, and add timeouts for async operations.
Mocks don't match real behavior
Mocks don't match real behavior
Mock implementations may be outdated. Validate mocks against actual API contracts, use contract testing for external services, and add integration tests to verify real interactions.
Generated tests import business logic
Generated tests import business logic
Tests may reimplement production code. Add the Require Test Coverage rule to your project on the platform to ensure tests import and use production code exclusively.
E2E tests are missing
E2E tests are missing
E2E scope may not be specified. Explicitly request integration and E2E tests in prompt, define user workflows to test, specify API contracts to validate, and include database state requirements.