Concepts

Testing Strategies

Approaches and testing levels for validating software works correctly, from unit tests to end-to-end tests and testing in production.

seed#testing#unit-tests#integration#e2e#tdd#quality

What it is

Testing strategies define what types of tests to write, how many, and how to organize them to maximize code confidence with the lowest maintenance cost.

Testing pyramid

        /\        E2E (few, slow, fragile)
       /  \
      /----\      Integration (some)
     /      \
    /--------\    Unit (many, fast, stable)

Test types

TypeWhat it testsSpeedFragility
UnitIsolated function/classVery fastLow
IntegrationComponents togetherMediumMedium
E2EComplete user flowSlowHigh
ContractAPIs between servicesFastLow

Approaches

ApproachMechanismWhen to use
TDDWrite test before codeBusiness logic, algorithms
BDDTests as behavior specificationsUser requirements, acceptance
Property-basedGenerate random inputs, verify invariantsParsers, serialization, edge cases
SnapshotCompare output with saved versionUI components, API responses

Testing in production

  • Feature flags for gradual rollout
  • Canary deployments
  • Observability to detect problems

Why it matters

An effective testing strategy balances speed, coverage, and confidence. Too many unit tests without integration give false security. Too many e2e tests are slow and brittle. The testing pyramid provides the framework for finding the right balance.

References

Concepts