End-to-end testing vs integration testing

Integration testing checks that two or more components work together correctly at the interface between them. End-to-end testing drives a complete user journey through the deployed system, third-party services included, the way a user would. An integration test fails at a named seam, and an end-to-end test fails somewhere along a whole journey.

The longer version

Follow one booking through a holiday-let site. The guest picks dates, the availability service confirms the cottage is free, the payment provider takes a deposit, the booking is written to the database and a confirmation email goes out. An integration test takes one seam from that chain, for example the booking service and the availability service, runs the two real components together and checks the exchange: the dates sent, the answer returned, the behaviour when the cottage has just been taken. End-to-end testing is testing that drives a whole journey through the deployed system as a user would, here from the first page to the email, with every component and third party in place. The ISTQB glossary files the two under different headings. Integration testing is "a test level that focuses on interactions between components or systems", and end-to-end testing is "a test type in which business processes are tested from start to finish under production-like circumstances".

A failure reads differently in each. An integration test that fails names an interface, with a suspect on either side of it. An end-to-end test that fails says the journey broke, and the cause may lie in any component, in the data, in the environment or in a third party that was slow that minute. End-to-end tests are also the costly ones to keep. Martin Fowler's test pyramid page describes tests that run end-to-end through the UI as "brittle, expensive to write, and time consuming to run", and argues for many more low-level unit tests than broad tests through a GUI. Kent C. Dodds drew a different shape, the testing trophy, as a guide for testing JavaScript applications, around a line he credits to Guillermo Rauch: "Write tests. Not too many. Mostly integration." Neither shape puts most of the tests at the end-to-end level. Fowler's page notes that some writers prefer more integration tests and fewer unit tests, and suggests the difference is probably illusory, a matter of different definitions of a unit test.

The two kinds of test complement each other. Integration tests, and contract tests where two teams own the two sides of an API, establish that each pair of components agrees. An end-to-end test then covers what no pairwise check can: that the whole chain is wired together in the deployed environment, with real configuration, real credentials and the real third party. Few are needed for that. The ISTQB Foundation Level syllabus says of high-level, end-to-end tests that usually just a few of them are needed to achieve a reasonable level of coverage, and the journeys chosen are the ones the business cannot do without, such as booking and paying. System integration testing is the stage that exercises the seams with real components in place. System testing, which is compared with integration testing in its own entry, judges the assembled product against its requirements. End-to-end testing borrows from both: it needs everything assembled, and it follows a journey where the others follow an interface or a list of requirements.

Side by side, the differences line up on five points. Scope: an integration test covers one interface between two or more components, and an end-to-end test covers a full journey through all of them. Environment: an integration test runs the components concerned with doubles standing in for the rest, and an end-to-end test needs the deployed system with its real configuration. Speed and number: integration tests are quick enough to run on every change and a suite holds many, while end-to-end tests are slow and a suite holds a few. Failure: an integration failure names a seam, and an end-to-end failure names a journey. Owner: integration tests are usually written by the developers of the components, and end-to-end tests by developers or testers working from the journeys the business depends on. When to use which: write an integration test wherever two components exchange data and the exchange can go wrong, and run it on every change. Write an end-to-end test for each journey whose failure would stop the business, such as sign-up, checkout or booking, and run that small set before each release and after each deployment.

Common questions

What is the difference between end-to-end testing and integration testing?

Integration testing checks the interaction between two or more components at their interface, with the real components in place. End-to-end testing drives a complete user journey through the whole deployed system, including external services. The first isolates a seam and the second proves the chain. End-to-end runs are slower and harder to diagnose, so a suite holds far fewer of them.

What is end-to-end testing?

End-to-end testing is testing that drives a complete user journey through the deployed system, from the user interface through every service and data store to the outside parties involved. The ISTQB glossary defines it as a test type in which business processes are tested from start to finish under production-like circumstances, and gives E2E testing as a synonym.

Are end-to-end tests a kind of integration test?

End-to-end tests exercise every integration at once, so in a loose sense they are the widest integration tests there are. The usual vocabulary keeps the names apart by purpose. An integration test targets one interface and reports on it, and an end-to-end test targets a user journey and reports on the outcome a user would see. ISTQB classes the first as a test level and the second as a test type.

Why are end-to-end tests slower and more brittle than integration tests?

An end-to-end test starts the whole system, works through a user interface and waits on every service in the chain, third parties included. Each run therefore takes longer and has more ways to fail for reasons unrelated to the code that changed. Martin Fowler's test pyramid page calls tests that run end-to-end through the UI brittle, expensive to write and time consuming to run.

Does a product need end-to-end tests if every integration test passes?

Passing integration tests show that each pair of components agrees, each pair in its own test setup. Only an end-to-end run shows that the pairs are wired together in the deployed environment, with the real configuration, credentials and third-party accounts. A wrong address for the payment provider in the production settings passes every integration test and fails the first real booking, so a handful of end-to-end journeys is worth keeping.

Is end-to-end testing the same as UAT?

End-to-end testing and user acceptance testing often follow the same journeys, and they answer different questions. An end-to-end test checks that the deployed system completes a journey correctly, and the team usually writes and automates it. User acceptance testing is done by the intended users or their representatives, who decide whether the product meets their needs. A journey can pass its end-to-end test and still fail acceptance because it does the wrong thing well.

What is an example of end-to-end testing?

A guest books a holiday cottage. The test opens the site, chooses dates, confirms availability, pays a deposit through the payment provider's sandbox, and checks that the booking is stored and the confirmation email arrives. Every component and third party in the chain takes part, which is what makes it end to end. An integration test would take one link of that chain, such as the booking service and the availability service, on its own.

Bug reports that arrive ready to triage.

Collect replay, console, network and browser context with the Free plan.

<script src="…/widget.js" data-key="pb_pub_…">