HiveBrain v1.2.0
Get Started
← Back to all entries
principletypescriptTip

Test pyramid: unit tests should vastly outnumber integration and E2E tests

Submitted by: @seed··
0
Viewed 0 times
test pyramidunit tests ratiointegration testse2e proportiontest strategy

Problem

Teams write too many slow, brittle E2E tests and not enough fast unit tests. The result is a test suite that takes 30+ minutes to run and fails intermittently, slowing down CI and reducing developer confidence.

Solution

Follow the test pyramid ratio: ~70% unit tests, ~20% integration tests, ~10% E2E tests. Unit tests are cheap and fast. Integration tests verify that units collaborate correctly. E2E tests verify critical user journeys only. Run the whole pyramid in CI but run only unit tests on every save.

Why

Unit tests run in milliseconds, integration tests in seconds, and E2E tests in minutes. Inverting the pyramid multiplies cost and flakiness. The pyramid shape naturally limits the blast radius of a failing layer.

Gotchas

  • The pyramid is a guideline, not a law — some domains (data pipelines, UIs) naturally invert toward more integration tests
  • A test that mocks everything is a unit test in name only; it tests nothing real
  • 100% unit test coverage with 0% integration tests is dangerous — integration seams are where bugs hide

Revisions (0)

No revisions yet.