When to use
When planning how to test a new feature, service, or system — or when an existing suite is slow, flaky, or gives false confidence. Coverage percentage is a means; the goal is catching regressions cheaply.
Not for: writing one specific test case (just write it), or chasing a coverage number for its own sake. This is strategy — the mix and the gate — not individual assertions.
Method
- Map the risk. List what breaking would hurt most: core business logic, money paths, auth, data integrity, external contracts. Test heaviest where risk is highest.
- Choose the mix along the pyramid. Unit tests for logic and edge cases (fast, many); integration tests for seams and real dependencies; end-to-end for critical journeys only (few, high-value). If e2e count is climbing, push cases down to cheaper layers.
- Cover the right cases: happy path, boundaries, error/failure paths, and known past bugs (regression). Include at least one adversarial/invalid-input case per surface.
- Decide isolation. Mock external systems and nondeterminism (clock, network, randomness); do not mock your own logic into meaninglessness. If a mock stops mirroring the real contract, it tests fiction — pin it to the real shape or use the real thing.
- Design for trust and speed. Tests must be deterministic, independent, and fast enough to run on every commit. A flaky test is a defect — quarantine and fix it, don't retry-loop around it.
- Define the gate: what must be green before merge vs. what runs nightly or pre-release.
Example
Feature: checkout discount codes.
Risk map: money path (High), code validation (High), UI banner (Low).
Mix: ~20 unit (validation, expiry, stacking rules, negative totals),
~5 integration (discount service + real DB),
1 e2e (apply valid code -> correct charged total).
Cases: valid, expired, already-used, malformed, discount > cart total.
Isolation: mock payment gateway; use real DB in integration.
Gate: unit + integration block merge; e2e runs pre-release.
Pitfalls
- Coverage theater — 90% coverage that never asserts on failure paths or money math.
- Inverted pyramid — slow, flaky e2e doing work a unit test should own.
- Over-mocking until tests pass regardless of whether the real code works.
- Tolerating flakes with retries instead of treating them as defects, eroding trust in green.
Output format
Risk map: <what to protect, ranked>
Test mix: unit / integration / e2e — rationale + rough counts
Coverage plan: <cases per critical area, including failure paths>
Mocking & isolation: <what's mocked vs. real, and why>
CI gate: <blocking suites vs. nightly/pre-release>
Gaps & risks accepted: <what you deliberately don't test, and why>
1---2name: eng-testing-strategy3version: 1.0.04description: Design a test strategy that matches test types to risk, targets meaningful cases over coverage percentage, and keeps the suite fast, deterministic, and trustworthy.5author: matrixx00706tags: [testing, test-strategy, coverage, quality, ci, pyramid]7capabilities: []8metadata:9 source: https://skillmd.com/skills/matrixx0070/eng-testing-strategy10---1112## When to use1314When planning how to test a new feature, service, or system — or when an existing suite is slow, flaky, or gives false confidence. Coverage percentage is a means; the goal is catching regressions cheaply.1516**Not for:** writing one specific test case (just write it), or chasing a coverage number for its own sake. This is strategy — the mix and the gate — not individual assertions.1718## Method19201. **Map the risk.** List what breaking would hurt most: core business logic, money paths, auth, data integrity, external contracts. Test heaviest where risk is highest.212. **Choose the mix along the pyramid.** Unit tests for logic and edge cases (fast, many); integration tests for seams and real dependencies; end-to-end for critical journeys only (few, high-value). If e2e count is climbing, push cases down to cheaper layers.223. **Cover the right cases:** happy path, boundaries, error/failure paths, and known past bugs (regression). Include at least one adversarial/invalid-input case per surface.234. **Decide isolation.** Mock external systems and nondeterminism (clock, network, randomness); do *not* mock your own logic into meaninglessness. If a mock stops mirroring the real contract, it tests fiction — pin it to the real shape or use the real thing.245. **Design for trust and speed.** Tests must be deterministic, independent, and fast enough to run on every commit. A flaky test is a defect — quarantine and fix it, don't retry-loop around it.256. **Define the gate:** what must be green before merge vs. what runs nightly or pre-release.2627## Example2829```30Feature: checkout discount codes.31Risk map: money path (High), code validation (High), UI banner (Low).32Mix: ~20 unit (validation, expiry, stacking rules, negative totals),33 ~5 integration (discount service + real DB),34 1 e2e (apply valid code -> correct charged total).35Cases: valid, expired, already-used, malformed, discount > cart total.36Isolation: mock payment gateway; use real DB in integration.37Gate: unit + integration block merge; e2e runs pre-release.38```3940## Pitfalls4142- **Coverage theater** — 90% coverage that never asserts on failure paths or money math.43- **Inverted pyramid** — slow, flaky e2e doing work a unit test should own.44- **Over-mocking** until tests pass regardless of whether the real code works.45- **Tolerating flakes with retries** instead of treating them as defects, eroding trust in green.4647## Output format4849```50Risk map: <what to protect, ranked>51Test mix: unit / integration / e2e — rationale + rough counts52Coverage plan: <cases per critical area, including failure paths>53Mocking & isolation: <what's mocked vs. real, and why>54CI gate: <blocking suites vs. nightly/pre-release>55Gaps & risks accepted: <what you deliberately don't test, and why>56```