Dev Overflow Logo

Dev Overflow

Global search

Search across questions, answers, users and tags.

Loading...
save

What is the difference between unit, integration, and e2e tests in practice?

clock icon

asked 2 months ago

message icon

2

eye icon

1.4K

Every team I have joined draws these lines differently, and the definitions in blog posts don't match what people actually write. Is there a useful practical distinction, or is it mostly vocabulary?

2 Answers

The definitions matter less than the trade-off they encode: the more of the real system a test exercises, the more confidence it gives and the slower and flakier it is.

A workable split:

  • Unit — one module, dependencies substituted. Milliseconds. Catches logic errors. Tells you nothing about whether the pieces fit together.
  • Integration — several real modules, real database, no browser. Seconds. Catches wiring, schema, and query errors, which is where most real bugs live.
  • E2E — the deployed app through a browser. Minutes. Catches "the deploy config is wrong" and little else that the layer below missed.

Most teams over-invest in the ends and under-invest in the middle. If you have a fixed budget, integration tests usually buy the most confidence per second of CI time.

Agreed on the middle layer. Docker Compose plus a throwaway database has made integration tests cheap enough that the old reasons for mocking everything mostly don't apply now.

1

of 1

Write your answer here

Introduce the problem and expand on what you've put in the title.

Top Questions