In the End-to-End (E2E) testing pyramid, tests occupy one of the top rungs. By writing one E2E test, you can be confident in the results of your application logic, test integrations with other systems, and create a "contract" for your application.
Unfortunately, many of the colleagues I worked with did not write E2E tests. Partly because they went headlong into unit testing and felt it was better for a number of reasons, including the TDD trend. Partly because they believed that E2E tests are difficult to write, they take a long time to execute, and there are problems with the instrumentation.
Let's sort out these opinions and look at the pros that E2E testing offers.
Terminology
Let's put the type of autotests under E2E tests. These autotests should cover all service functions from the client's point of view. They do this by simulating the actual client interaction, be it an HTTP request or clicking a button in the UI.
The unit testing approach is better
Writing unit tests, in my experience, takes a lot longer than E2E tests. Yes, at first you will have to figure out how E2E tests are better to write, but the same was true for unit tests.
On the other hand, as a result, one E2E test covers more code than one Unit test, although it may take fewer lines compared to a similar unit test suite.
You don't have to waste time on understanding how to mock dependencies correctly, because external systems become them in E2E tests, and interaction with the service under test is built according to the "black box" principle.
You don't need to check all the boundary conditions for a single class method. This increases the flexibility of working with the code, since there is no need to refactor the entire test suite at the slightest change in the internal logic of the application.
, , 100 ( ), .
backend- , API HTTP ( GraphQL) MQ. HTTP, mainstream .
Frontend- , , Web- () . , , , .
E2E , . . .. . , .
E2E
, , .
"" code-coverage. , , , , . exception, , ?
, E2E .
E2E API . , backend, E2E , , frontend .
, , E2E , unit-, .
! , E2E ?