DEV Community

Panda Quests
Panda Quests

Posted on • Updated on

What are the differences between unit tests, integration tests, e2e tests, and acceptance tests?

Top comments (1)

Collapse
 
sargalias profile image
Spyros Argalias

Unit tests, integration tests and even acceptance tests or end to end tests overlap a lot. I consider the main differences to be:

  1. The amount of code under test.
  2. How much the test reflects the end user's experience.

In terms of size, they overlap. End to end tests can be very small (e.g. testing that a page displays the correct title) or very large (e.g. testing that a main feature works). A unit test can test a single small function, or it can test a function which calls many other functions (like a mini-integration test). However, often, unit tests are small, integration tests are larger and end to end tests are even larger.

The second consideration is how closely the test matches the end user's experience. An end to end test or acceptance test matches the user's experience very closely. For example, when doing end to end testing with Cypress, you essentially simulate the end user using your website. An integration test which tests a feature in code (without rendering it and without network requests) is "further away" from the user's experience, but it may still test an entire feature which an end user would understand. A small unit test is something much further from the end user, they wouldn't be interested about those low level details..

TLDR: They overlap a lot. I don't think we have anything which clearly categorizes them in all cases. Consider the amount of code under test and how closely the test reflects the user's experience.