Introduction to End-to-End Testing
End-to-end testing (E2E) examines the real-world scenarios of an application from start to finish, touching as many functional areas and parts of the application’s technology stack as possible. Compared to unit tests, which are narrow in scope, E2E tests have a broad scope, and so are sometimes called “broad stack” or “full stack” tests. E2E tests focus on validating the workflows of an application from the perspective of the end-user, which makes them highly valued by management and customers. E2E testing is usually performed last in the testing process, following lower-level unit, integration, and system testing. Despite their value, automated E2E tests can be complex to build, fragile, and challenging to maintain. As a result, a common approach is to plan a smaller number of E2E tests than unit and integration tests, as shown in the test automation pyramid. E2E testing is conducted in as realistic an environment as possible, including the use of back-end services and external interfaces such as the network, database, and third-party services. Because of this, E2E testing can identify issues such as real-world timing and communication issues that might be missed when units and integrations are tested in isolation.
Assume that you are testing a web shopping platform that requires a third party to validate payment details. This application might contain E2E tests such as the following:
- User logs on, searches for an item, puts the item in the cart, selects payment and shipping details, and then checks out and logs off.
- Use logs on, searches for an existing order that has been shipped, reviews the tracking information, and receives a detailed response on the delivery of the order, then logs off.
- User logs on, searches for an existing order that has been shipped, requests a return of the order, receives a shipping label to return the item, and logs off.
- User logs on, opens their account information, adds a new payment type, receives verification that the payment type is valid, and logs off.
These tests will access third-party services such as payment verification and shipment tracking, as well as one or more databases for customer information, inventory, orders, and more.
Best Practices for E2E Testing
A typical E2E test can be complex, with multiple steps that are time-consuming to do manually. This complexity can also make E2E tests difficult to automate and slow to execute. The following practices will help manage the costs of automated E2E testing while maintaining the benefits.
Keep an end-user perspective
Limit exception testing
Apply risk analysis
Test in the right order
Manage your test environment
Separate test logic from your UI element definitions
Handle waits for UI elements appropriately
Choose the right devices
Optimize your setup/teardown process
It’s important to plan manual and exploratory testing as part of your E2E testing, to address difficult-to-automate aspects such as usability and user experience. And, to ensure that you have a complete and well-balanced set of tests,