Testing Pyramid
Practical reference for test levels, tooling, and strategy.
Based on: The Testing Pyramid: Everybody Knows It, Nobody Follows It
The Pyramid
▲
/E2E\ few — critical user flows only
/─────\
/ \
/ Integra-\ moderate — component interactions, API contracts
/ tion \
/─────────────\
/ \
/ Unit Tests \ many — all business logic, validation, edge cases
/─────────────────\
| Layer |
Speed |
Count |
Tool |
| Unit |
0.001–0.01 s |
Thousands |
pytest |
| Integration |
0.1–1 s |
Hundreds |
pytest + Playwright APIRequestContext |
| E2E |
5–30 s |
Tens |
Playwright (browser) |
Sections
1. Unit Tests
2. Integration Tests
3. E2E Tests
| File |
Topics |
| Concept & Examples |
Browser automation with Playwright, stable locators, user flows |
| Common Mistakes |
Fragile selectors, no auto-wait, testing every validation E2E |
4. Pyramid Strategy
Quick Decision Guide
| What you need to test |
Level |
| Single function, validation rule, calculation |
Unit |
| API endpoint → database round trip |
Integration |
| Service A calls Service B |
Integration |
| User completes a full workflow in browser |
E2E |
| Field-level form validation in the UI |
Unit (not E2E) |
| Auth contract between two services |
Integration (contract) |
Anti-Pattern: Ice Cream Cone
/─────────────────\
/ E2E (many!) \ ← slow, flaky, 40+ min CI
/─────────────────\
/ \
/ Integra-\ ← almost none
/ tion \
/─────────────\
/ \
/Unit\ ← barely any
/──────\
Happens when teams skip unit and integration tests during development
and try to cover everything with Playwright at the end.
See also