Glossary · Programming

Integration Test

An integration test checks that multiple components, such as code, a database and an external service, work correctly together rather than in isolation.

Updated October 6, 2026

An integration test verifies that several parts of a system work correctly together. Where a unit test checks one function or class in isolation, an integration test exercises real interactions, such as application code talking to a database, a message queue or another service.

Why it matters

Many bugs live at the boundaries: a wrong column name, a mismatched JSON field, a misconfigured connection or a transaction that behaves differently than expected. Unit tests with mocks cannot catch these. Integration tests give confidence that the pieces fit, at the price of being slower, harder to set up and more likely to be flaky. A common strategy is many fast unit tests, fewer integration tests and a small number of end-to-end tests, often called the test pyramid.

Example

def test_create_and_fetch_user(db):         # db is a real test database
    repo = UserRepo(db)
    repo.create(name="Ana", email="ana@example.com")
    user = repo.find_by_email("ana@example.com")
    assert user.name == "Ana"

The test uses a real database, so it also validates the schema and SQL.

Common mistakes

  • Sharing state between tests so they pass or fail depending on order.
  • Calling live third-party services, causing flaky failures.
  • Leaving test data behind instead of resetting the database.

Get notified when this term updates

Plus occasional practical tips on uptime and monitoring, nothing else. Unsubscribe anytime.

This page is general information written by our editorial team and updated when documentation changes. Servers and providers differ, so test changes safely first. See our editorial policy and disclaimer.