Skip to content

Test strategy and the test portfolio

A test strategy says what kinds of tests a system needs, at which boundaries, and who owns them. It’s an architecture decision, because the right mix depends on the system’s shape. A modular monolith and a set of thirty microservices need very different strategies, even if their features are identical.

The goal isn’t maximum coverage. It’s fast, trustworthy feedback: every change should be proven safe quickly enough that people keep running the tests, and the tests should fail only when something is really wrong.

Each kind of test covers a different boundary1. Unit and component tests run the orders service alone, with dependencies replaced by test doubles. Fast, and most of the suite. 2. Contract tests check that orders and payments still agree on their API, without deploying both together. 3. Integration tests check the service against real infrastructure, such as its own database in a container. 4. A small number of end-to-end tests run the most important user journeys across the whole system. Web appuser journeys Orders servicethe code under test Payments serviceanother team Test doublesfakes, stubs, mocks Real databasein a container Provider sandboxor virtual service4213
Each kind of test covers a different boundary Most confidence comes from fast tests at the service level; a few end-to-end journeys confirm the whole works together.
  1. Unit and component tests run the orders service alone, with dependencies replaced by test doubles. Fast, and most of the suite.
  2. Contract tests check that orders and payments still agree on their API, without deploying both together.
  3. Integration tests check the service against real infrastructure, such as its own database in a container.
  4. A small number of end-to-end tests run the most important user journeys across the whole system.
Test type Scope Speed Catches Typically owned by
Unit One function or class Milliseconds Logic errors Developers
Component (service) One service, dependencies faked Seconds Behavior of the service through its API The service team
Contract The agreement between a consumer and a provider Seconds Breaking API or message changes Both teams, checked in each pipeline
Integration A service with real infrastructure (database, broker) Seconds to minutes Queries, mappings, configuration, transactions The service team
End-to-end Several services through the UI or API Minutes Wiring and critical journeys Shared, kept small
Non-functional Performance, security, accessibility, resilience Minutes to hours Quality attribute failures Test architects with specialists
In production The live system Continuous What only real traffic reveals Product and operations teams
  • Shape follows architecture. The classic test pyramid (many unit tests, fewer integration tests, very few UI tests) suits a monolith. For microservices, many teams prefer a “honeycomb” with most tests at the service level and few pure unit tests, because the risk lives in integrations. Use the shape that matches where your failures come from.
  • Test at the boundaries the architecture defines. Each service’s public API is a natural test boundary. Tests that reach inside another team’s service are fragile.
  • Contract tests replace most end-to-end tests between services. With consumer-driven contracts (for example, using Pact), each consumer publishes the requests it relies on, and the provider’s pipeline verifies them. A breaking change fails the provider’s build, before deployment.
  • Keep end-to-end tests few and critical: sign-up, checkout, payment, the journeys that would make the news if broken. Every extra one adds minutes and flakiness.
  • Test quality attributes explicitly. Each quality attribute scenario should map to a test: a load test, a failover drill, a security scan, an accessibility check.
  • Shift right as well as left. Feature flags, canary releases, synthetic monitoring and observability test in production safely. Some failures only appear with real data and traffic.
  • Treat flaky tests as defects. A test that fails randomly teaches people to ignore failures. Quarantine it and fix or delete it.
  • Make risk visible. State what is not tested and why, so the decision is conscious.
  • Fast feedback: most problems are found in seconds or minutes, by the team that caused them.
  • Independent releases: contract tests let teams deploy without coordinated test cycles.
  • Confidence in quality attributes, not just features.
  • Needs developer ownership; a separate QA team can’t write unit, component and contract tests for everyone.
  • Contract testing needs discipline and a shared broker or repository for contracts.
  • Test doubles can drift from the real thing if contracts aren’t verified.

Write an explicit test strategy for every significant system, and revisit it when the architecture changes, for example when splitting a monolith or adding asynchronous messaging.

Don’t write a heavy, generic strategy document for a small internal tool. A short page answering “what do we test, where, and who owns it?” is enough.

  • The ice-cream cone: mostly manual and UI tests, few fast tests underneath. Slow, flaky and expensive.
  • A shared end-to-end environment as the only quality gate, so every team waits on every other team.
  • Mocking what you don’t own without contract tests, so the mocks lie.
  • Coverage targets as the goal, rewarding tests that execute code without checking anything.
  • No test owner for non-functional requirements until a performance problem reaches production.

Written and edited by Abhinav Taduka, enterprise software architect.