# Testing Pyramid Status: public Confidence: medium (0.725) (verified) Last verified: 2026-06-01 Generation: ai_assisted ## TL;DR The testing pyramid is a practical rule for AI coding agents: generate many small, fast checks near the code, fewer integration checks, and a small number of end-to-end checks for critical user flows. ## Core Explanation Agents can quickly overproduce brittle browser tests because they are easy to describe in natural language. A healthier workflow asks the agent to first add or update unit and integration tests that isolate the changed behavior, then reserve browser tests for user-visible flows that need full-system confidence. ## Source-Mapped Facts - Martin Fowler describes the test pyramid as a way to balance automated tests with more low-level unit tests than high-level GUI-driven tests. ([source](https://martinfowler.com/bliki/TestPyramid.html)) - The Practical Test Pyramid describes Mike Cohn's original pyramid as three layers: unit tests, service tests, and user interface tests. ([source](https://martinfowler.com/articles/practical-test-pyramid.html)) - Google Testing Blog recommends a pyramid-shaped first guess of 70% unit tests, 20% integration tests, and 10% end-to-end tests. ([source](https://testing.googleblog.com/2015/04/just-say-no-to-more-end-to-end-tests.html)) - Playwright best practices recommend web-first assertions because Playwright waits until the expected condition is met. ([source](https://playwright.dev/docs/best-practices)) ## Operational Notes for AI Coding Agents Ask the agent to state the intended test layer before writing tests. For implementation changes, prefer a failing unit or integration test first. For browser automation, require stable locators, web-first assertions, and a clear reason why lower-level tests are insufficient. ## Further Reading - [Test Pyramid](https://martinfowler.com/bliki/TestPyramid.html) - [The Practical Test Pyramid](https://martinfowler.com/articles/practical-test-pyramid.html) - [Just Say No to More End-to-End Tests](https://testing.googleblog.com/2015/04/just-say-no-to-more-end-to-end-tests.html) - [Playwright Best Practices](https://playwright.dev/docs/best-practices)