Unit Testing
Unit tests examine individual, isolated units of source code and ensure that they function internally as intended.
A typical example: In an online store, a product can be added to the shopping cart. A unit test test doesn't check whether the button is clickable or if the page layout looks correct. Instead, it verifies the underlying logic: Was the item added correctly? Is the quantity accurate? Is the total price calculated and saved properly? This business logic is tested in isolation, independent of the rest of the application.
The goal is to pinpoint bugs as early as possible: If a unit test fails, the affected code section can be identified immediately. Unit tests are written by developers, typically run automatically, and accompany development from the very start.
Component Testing
Once individual units have been tested, larger, self-contained components of a system are tested, such as an entire module or service. Component tests evaluate a component’s behavior as independently as possible from other parts of the system. Dependencies on other parts of the system are not taken into account.
Returning to our shopping cart example, where a product is added to the cart: A component test does not check the business logic behind it, but rather whether the component behaves correctly: Does the "Add to Cart" button disable once the product is already in the cart? Does a success message appear after clicking? Does the component display a loading state while the request is processing? This UI behavior is tested in isolation.
Integration Testing
Integration testing verifies whether interdependent components interact correctly with one another: whether data is passed correctly, if logic works together, and whether the system as a whole behaves as expected.
The shopping cart example allows you to verify not only whether an order is processed correctly within a single component, but also whether the order is actually saved correctly in the database. This uncovers bugs that remain hidden during isolated unit or component tests, where individual parts work on their own but fail when integrated.
API Testing
API tests are sometimes part of integration tests, but they focus on communication between defined interfaces. They verify that APIs return the correct data, respond correctly to requests, and remain stable under various conditions, regardless of what is happening at the user interface.
Example: When a product is added to the cart, an API test checks the backend interface: Does the endpoint return the expected data payload and status codes? Does the API react appropriately if an item is out of stock? This communication can be tested independently of the front end using tools like Postman or custom scripts.
End-to-End Testing
End-to-end (E2E) tests simulate complete workflows from the perspective of all users interacting with the software. Multiple user stories are tested in sequence to verify the interplay of the entire system and ensure data flows correctly across system boundaries. These tests are typically executed toward the end of a development cycle.
Our shopping cart example now becomes a complete workflow: Searching for a product, adding it to the cart, completing checkout, and receiving an order confirmation all touch the user interface (UI) used by the end customer. But E2E testing goes further: for example, it also verifies whether the ERP system generates the correct picking list for warehouse staff. An end-to-end test checks whether processes function as intended from start to finish.