Chapter 2 of 10All chapters
Chapter 2 of 10
Kinds of test
The pyramid, and why it is that shape.
Three levels
Unit tests check one piece in isolation and run in milliseconds. Integration tests check that pieces work together, including real databases. End to end tests drive the whole system as a user.
- Many unit, some integration, few end to end: fast feedback where it is cheapest.
- End to end tests find the most realistic bugs and are the slowest and most brittle.
Other useful kinds
Property based tests generate many inputs and check a rule holds. Snapshot tests catch unintended output changes. Contract tests keep two services agreeing about their interface.