What it catches
A unit test of the booking function passes, yet saving fails in production because a database column is named differently or a required field is missing in the payment provider's request. An integration test sends a booking through the code to a test database and checks the stored row.
Practical setup
- Run against a real database engine started in a container instead of a fake, so SQL differences show up.
- Use a provider's sandbox or a recorded mock for outside APIs, and run a small number of live contract checks separately.
- Reset data between tests so they do not depend on order.
Trade-offs
These tests are slower and need more setup than unit tests, and a failure takes longer to diagnose. Keep them focused on boundaries: data access, API endpoints, message handlers and third-party calls.
Teams run them on every pull request in a CI pipeline. A web endpoint test that sends an HTTP request and checks the response and stored data is the most common form.
Questions, answered
Integration tests exercise a few connected parts; end-to-end tests drive the whole product through the user interface.
For integration tests, prefer a real test database. Mocks can hide mistakes in queries.