top of page
HyperTest_edited.png
20 June 2024
14 Min. Read

End-to-End Testing: A Detailed Guide

End-to-End Testing: A Detailed Guide

Fast Facts

Get a quick overview of this blog

  1. Map key user flows and build E2E tests that mimic real user actions, ensuring a seamless user experience.

  2. Leverage data-driven testing frameworks and tools to manage test data efficiently across environments.

  3. Automate core E2E tests for faster execution, but keep manual testing for exploratory scenarios.

💡 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:

The Benefits of E2E testing
  • 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.
Key Components of End-to-End Testing

Code Coverage Challenge

Quick Question

Are you planning to build Test Automation Suite?

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.



Example of End-to-End Testing


Example of End-to-End Testing

Consider an application with a user authentication system. An E2E test scenario might include:


  • User Signup: Navigate to the signup page, fill out the form, and submit.


  • Form Submission: Submit the signup form with user details.


  • Authentication: Verify the authentication process using the provided credentials.


  • Account Creation: Ensure the account is created and stored in the database.


  • Login Service: Log in with the newly created account and verify access.


Types of End-to-End Testing


There are two types of End-to-End Testing: Vertical E2E testing and horizontal E2E testing. Each type serves a different purpose and approach. Let’s have a quick look at both:


⏩Vertical E2E Testing


Vertical E2E testing focuses on testing a complete transaction or process within a single application. This type of testing ensures that all the layers of the application work together correctly. It covers the user interface (UI), backend services, databases, and any integrated systems.


Example:

Consider a banking application where a user transfers money. Vertical E2E testing would cover:


  1. User logs into the application.

  2. User navigates to the transfer money section.

  3. User enters transfer details and submits the request.

  4. The system processes the transfer.

  5. The transfer details are updated in the user’s account.


⏩Horizontal E2E Testing


Horizontal E2E testing spans multiple applications or systems to ensure that they work together as expected. This type of testing is important for integrated systems where different applications interact with each other.


Example:

Consider an e-commerce platform with multiple integrated systems. Horizontal E2E testing would cover:


  1. User adds a product to the shopping cart on the website.

  2. The cart service communicates with the inventory service to check stock availability.

  3. The payment service processes the user's payment.

  4. The order service confirms the order and updates the inventory.

  5. The shipping service arranges for the product delivery.


Best Practices for End to End Testing


Implementing E2E testing effectively requires following best practices to ensure thorough and reliable tests. Here are some key practices to consider:


  • E2E tests hitting API endpoints tend to be more useful than hitting a website. This is because it tends to break less, be more reliable, and easier to maintain.


  • Focus on the most important user journeys. Prioritize scenarios that are critical to the business and have a high impact on users.


  • E2E tests on an existing codebase often requires ALOT of test setup, and that can be very fragile. If E2E testing takes a lot of work to get setup, then chances it will become easily broken, as people develop. This will become a constant burden on development time.