What is the testing pyramid in CI/CD and where does each test type run?
Answer
The testing pyramid (by Mike Cohn) recommends having many unit tests at the base, fewer integration tests in the middle, and a small number of end-to-end tests at the top. In a CI/CD pipeline: Unit tests (base) run on every push — fast (seconds), test business logic in isolation, should be thousands of them. Integration tests run after unit tests — test a service with its real database and dependencies (using Testcontainers or a test environment), slower (minutes), catch wiring and SQL bugs. Contract tests (Pact) run in CI — verify service API compatibility without a full environment. End-to-end (E2E) tests run against staging — simulate real user flows in a full deployed environment, slowest (tens of minutes), kept to a minimum covering critical user journeys. The pyramid shape enforces investing most effort where tests are fastest and cheapest to run.
Previous
What are feature flags and how do they integrate with CI/CD?
Next
What are code quality gates (SonarQube, coverage thresholds) in CI/CD?
More CI/CD Pipelines Questions
View all →- Intermediate What is blue-green deployment and how does it achieve zero-downtime releases?
- Intermediate What is a canary release and how does it reduce deployment risk?
- Intermediate What is a rolling deployment and how does it compare to blue-green?
- Intermediate What are feature flags and how do they integrate with CI/CD?
- Intermediate What are code quality gates (SonarQube, coverage thresholds) in CI/CD?