Lesson 12 / 23
Unit vs Integration Tests in a Pipeline
Compare unit, integration and end-to-end tests in a pipeline and balance speed against coverage.
Unit tests
Unit tests check one function or component in isolation, with dependencies mocked out. They're fast — hundreds run in seconds — so they run on every single commit.
Integration tests
Integration tests check that real pieces work together — an API talking to a real database, a service calling another service. They're slower and often run after unit tests pass, or on a schedule.
The testing pyramid
Keep many fast unit tests at the base, fewer integration tests in the middle, and very few slow end-to-end tests at the top. An inverted pyramid makes CI slow and flaky.