Test Strategy Design
Purpose
Design a comprehensive testing strategy for a project or module, selecting the appropriate mix of test types, tools, and coverage targets based on the system's risk profile, architecture, and team capabilities.
When to Use
- •Starting a new project and establishing testing practices
- •Reviewing and improving an existing test strategy
- •Adding a new module or service that needs a testing plan
- •Preparing for a production launch or compliance audit
- •After an incident that revealed testing gaps
Steps
Step 1: Understand the System
Gather context:
- •Architecture: Monolith, microservices, serverless, frontend SPA, etc.
- •Languages: Go, Python, TypeScript, etc.
- •Critical paths: What operations must never fail? (payments, auth, data integrity)
- •Risk profile: Financial, healthcare, consumer, internal tool?
- •Team size and experience: How much testing infrastructure can they maintain?
- •Existing tests: What exists? What's the current coverage? Any known gaps?
Step 2: Map Test Types to System Layers
| System Layer | Primary Test Types | Secondary Test Types |
|---|---|---|
| Domain/business logic | Unit, property-based | Mutation |
| API handlers | Integration, contract | Fuzz |
| Data access | Integration (with real DB) | Property-based |
| External integrations | Contract, integration | E2E |
| Frontend components | Component, snapshot | Visual regression, a11y |
| User journeys | E2E | BDD/acceptance |
| Infrastructure | Smoke | Chaos |
| Security | SAST/DAST, fuzz | Penetration |
Step 3: Define the Test Pyramid
Determine the distribution based on the architecture:
Backend-Heavy System:
code
Unit (60%) > Integration (25%) > E2E (10%) > Smoke (5%) Property-based and fuzz tests supplement unit tests on critical paths.
Frontend-Heavy System:
code
Component (50%) > Integration (20%) > Visual (10%) > E2E (10%) > A11y (10%)
Full-Stack Application:
code
Unit/Component (50%) > Integration (25%) > E2E (10%) > Visual/A11y (10%) > Smoke (5%)
Step 4: Select Tools per Test Type
For each test type in the strategy, select tools based on the language and ecosystem:
Go:
| Test Type | Tool |
|---|---|
| Unit | testing + testify |
| Property-based | pgregory.net/rapid |
| Fuzz | Native testing.F |
| Integration | testcontainers-go |
| E2E | net/http/httptest |
| BDD | godog |
| Mutation | go-mutesting |
Python:
| Test Type | Tool |
|---|---|
| Unit | pytest |
| Property-based | hypothesis |
| Fuzz | atheris |
| Integration | testcontainers |
| BDD | pytest-bdd |
| Mutation | mutmut |
TypeScript:
| Test Type | Tool |
|---|---|
| Unit | vitest or jest |
| Property-based | fast-check |
| Component | @testing-library/react |
| Visual | Playwright screenshots or Chromatic |
| A11y | jest-axe + @axe-core/playwright |
| E2E | Playwright |
| Snapshot | Vitest/Jest built-in |
| BDD | cucumber-js + playwright-bdd |
| Mutation | Stryker |
Step 5: Define Coverage Targets
Set realistic, risk-adjusted targets:
| Module Risk Level | Line Coverage | Branch Coverage | Mutation Score |
|---|---|---|---|
| Critical (financial, auth) | 90%+ | 85%+ | 85%+ |
| High (core business logic) | 85%+ | 80%+ | 75%+ |
| Medium (API, services) | 80%+ | 75%+ | 70%+ |
| Low (utilities, config) | 70%+ | 65%+ | 60%+ |
Step 6: Design CI Pipeline Integration
Map test types to pipeline stages:
yaml
on_every_commit: - lint - unit tests - component tests - accessibility tests (axe) on_pull_request: - all of the above - integration tests - snapshot tests - visual regression tests - mutation tests (incremental, changed files only) on_merge_to_main: - all of the above - E2E tests - smoke tests - full mutation testing nightly: - fuzz testing (extended duration) - property-based tests (extended examples) - performance/load tests - security scanning (SAST/DAST)
Step 7: Establish Test Quality Standards
Define standards for test code itself:
- •Naming:
TestFunctionName_Scenario_ExpectedBehavior(Go),it('does X when Y')(JS) - •Structure: Arrange-Act-Assert (unit), Given-When-Then (BDD)
- •Independence: Tests must not depend on execution order
- •Speed: Unit < 100ms, integration < 5s, E2E < 30s per test
- •Determinism: No flaky tests allowed in main branch
Step 8: Plan for Maintenance
- •Flaky test quarantine: Move flaky tests to a separate suite, fix within 1 sprint
- •Test debt tracking: Track untested modules and weak test areas
- •Coverage trending: Monitor coverage trends over time (never let it decrease)
- •Regular strategy reviews: Quarterly review of test strategy effectiveness
Output Format
Produce:
- •Test strategy document mapping test types to system layers
- •Tool selection matrix with justifications
- •Coverage targets per module/risk level
- •CI pipeline configuration showing when each test type runs
- •Test quality standards and naming conventions
- •Maintenance plan for ongoing test health