06-testing

Testing Strategy

06-testing/testing-strategy

Testing Strategy

Overview

Testing strategy is the plan for what to test at each level and why.


Why It Matters

A good strategy prevents duplicate tests, missing coverage, and wasted maintenance effort.


Core Concepts

  • Unit tests cover logic.
  • Integration tests cover boundaries.
  • E2E tests cover critical journeys.

Mental Models

Use the cheapest test that gives the confidence you need.


Best Practices

  • Test the riskier paths more deeply.
  • Prefer behavior coverage over implementation coverage.
  • Use each test layer for what it does best.

Common Mistakes

  • Overloading one test layer to do everything.
  • Writing brittle tests for low-value behavior.
  • Skipping regression tests after bugs.

Trade-offs

More tests improve confidence, but too many overlapping tests slow down development and maintenance.


Decision Framework

flowchart TD
  A[What changed?] --> B{Logic only?}
  B -->|Yes| C[Unit test]
  B -->|No| D{Boundary involved?}
  D -->|Yes| E[Integration test]
  D -->|No| F{Critical user flow?}
  F -->|Yes| G[E2E test]

Examples

  • Unit test for data mapping.
  • Integration test for API + UI flow.
  • E2E test for sign-in.

Checklists

  • Did I choose the right test level?
  • Is the risk covered?
  • Are tests keeping the suite fast enough?

Senior Engineer Notes

Senior engineers design tests as a portfolio, not as a pile. Each layer should earn its place.


Further Reading