💡 I am a senior SWE at a large tech company. I started on a legacy tool that has multiple repos (frontend, backend, and some other services) and has no automated interface testing. We do have a QA team that runs through scenarios, but that's error prone and expensive. In reality, a lot of our defects are encountered by users in prod (sad).
I have had mixed experience with e2e testing in the past: challenging to maintain with a lot of moving parts, sometimes flakey, challenging to coordinate between repos moving at different speeds.Relatable, right?
That’s the story of every other SWE!
E2E tests are good only when they’re working correctly and navigating the actual failure instead of any other broken parts.
But this is not a guide to tell the reality-check of E2E tests. INSTEAD, this guide is here to tell you everything about End-to-end tests. We’re not going to discuss only about the positive and how-to sides of this top segment of the testing pyramid.
This is more like a raw version of everything E2E, which talks both about the + and - of it.
End-to-End testing: The most debatable part of the pyramid
E2E tests are the ones that tests your whole app in one go. Interesting?
Superficially, yes! But when you dig deep and gain more knowledge on this, you’ll also find yourself debating about keeping it or leaving it within your team.
A formal introduction on E2E tests⬇️:
End-to-end testing is a method of testing the entire software application from start to finish. The goal is to validate the system as a whole and ensure that all integrated components work together as expected. E2E testing simulates real user scenarios to identify any issues with the system's interaction and data integrity across different layers.
Basically, E2E tests can test your system under two conditions:
all your services, databases and other dependent components need to be kept up and running: Simulating a live scenario
mocking or stubbing any external dependencies as per your convenience to allow for controlled and repeatable testing
Why is end-to-end testing important?
1. Covers the Entire Application:
End-to-end testing checks the entire flow of an application from start to finish. It ensures all parts of the system work together as expected, from the user interface down to the database and network communications.
2. Detects System-Level Issues:
E2E helps identify issues that might not be caught during unit testing or integration testing, such as problems with data integrity, software interactions, and overall system behavior.
3. Mimics Real User Scenarios:
It simulates real user experiences to ensure the application behaves correctly in real-world usage scenarios. This helps catch unexpected errors and improves user satisfaction.
The Benefits of End-to-End testing
In an ideal scenario when E2E test is running smoothly and finding the right defects and bugs, it has potential to offer tremendous help:

E2E can often be the most straightforward or apparent way to add testing to an existing codebase that’s missing tests.
When it's working, it gives a lot of confidence when you have your most important use cases covered.
E2E tests for basic sanity checks (i.e. just that a site loads and the page isn’t blank) is very useful and are always good to have.
Key Components of End-to-End Testing
💡 Yes, E2E can be flaky, yes they can be annoying to keep up to date, yes their behavior can be harder to define, yes they can be harder to precisely repro. However, they can test behavior which you can't test otherwise.
Steps in End-to-End Testing
💡 Writing a couple of e2e (UI) tests is ok though. The key is to not overdo it. E2E tests are really complex to maintain.Requirement Analysis: Understand the application requirements and user workflows.
Test Planning: Define the scope, objectives, and approach for E2E testing.
Test Design: Create detailed test scenarios and test cases.
Test Environment Setup: Prepare the test environment to mimic production.
Test Execution: Run the test scenarios using automated tools.
Test Reporting: Document the results and identify any defects.
Defect Retesting: Fix and retest any identified defects.
