Integration and Functional Testing
Test how components work together for real.
Beyond the Unit
Unit tests prove a class works in isolation with everything mocked. But mocks can lie — the real database, framework router, or HTTP layer behaves differently. Integration tests verify two or more real components wired together; functional tests exercise the application end-to-end through its public entry point (an HTTP request, a console command). This lesson positions and writes both.
The Test Pyramid
A healthy suite is shaped like a pyramid:
- Many unit tests — fast, isolated, run constantly.
- Fewer integration tests — real DB/queue/cache, slower.
- Few functional/E2E tests — full stack, slowest, most brittle.
Inverting this (an 'ice-cream cone' of mostly E2E tests) yields a slow, flaky suite. Push coverage down whenever possible.
All lessons in this course
- The Test-Driven Development Workflow
- Mocking and Stubbing with Mockery
- Integration and Functional Testing
- Mutation Testing with Infection