Optimizing Software Quality: A Comprehensive Test Pyramid Approach

Elif Parlak
Mercury Business Services
5 min readNov 27, 2023

In the software development lifecycle, the earlier an error is detected the less expensive it is to fix.

The Testing Pyramid Framework

Testing Pyramid is an ideal automation framework that will help both developers and QAs create high-quality software, especially in Dev-OPS structured projects. It reduces the time required for developers to identify whether a change they introduced breaks the code. It also helps to build a more reliable test suite with fewer manual tests.

The testing pyramid is a model that breaks automated tests into three main categories: (1) the base layer: unit tests, (2) the middle layer — integration tests, and (3) the top layer — end-to-end tests.

Base Layer: Unit Tests

Unit Tests form the base of the testing pyramid. In this stage, individual components or functionalities are tested to validate that they work as expected in isolated conditions. Unit tests should be written before any code is written for a project, which helps to ensure higher quality code. Ideally, unit tests should be executed frequently and quickly. This allows developers to identify and fix issues early in the development process, which saves time and resources in a timely manner.

Middle Layer: Integration Tests

Integration tests form the second layer of the test automation pyramid. How a feature communicates with external dependencies should be tested at this stage. Whether it’s a call to a database or a web service, the software needs to communicate effectively and retrieve the correct information in order to work as expected. It should be known that it is important to carry out contract tests along with integration tests at this layer, especially in this period when the monolith architecture has become obsolete and communication with microservices and external APIs has intensified. Contract testing focuses on comparing the types of data exchanged between the customer and the provider against a contract file.

Top Layer: End-to-End Tests

At the top of the pyramid is end-to-end testing. End-to-end testing provides greater confidence in making sure the application works flawlessly from start to finish. The needs are mostly met with UI automation.

Responsibilities and Collaboration

The testing process should be divided into smaller chunks for increased efficiency. The QA team and software developers should write tests based on the test automation pyramid in collaboration with the project management team.

Ideal Test Pyramid with Responsibilities

As you see in the above figure, unit tests, component tests, contract tests, and backend API tests are written by the software developers. The automated API tests, automated UI tests, and performance tests are written by SDETs. The last part is executed manually by QA team members.

Environments and Test Activities

Environments with Test Activities

Before starting to write code for the project, the process should start with writing unit tests. In this way, it will also help to write better-quality code. Coverage rates for unit tests should be decided with the project stakeholders, and the CI pipeline should be configured so that deployments are not made with tests that do not meet the coverage rate. Developments that pass unit testing should be merged and released into the development environment.

All of the tests that should run in the development environment should be run by developers and this environment should be the responsibility of the developers. In the development environment, backend integration tests, contract tests, and API tests should be run and when all tests pass, the version should be deployed into the “Test” environment.

When the deployment is deployed to the test environment, UI test automation and the API automation suits should be triggered and run. In the test environment, functional tests of newly developed features with sanity testing, exploratory tests, API tests with close-to-real data, or by mocking (depending on 3rd Party environments) should be run manually. The test environment should be the responsibility of the QA Team. If all tests are completed without a critical bug, a new version should be pushed into the staging environment and the code should be frozen in the staging environment with this version.

In each version deployment to the staging environment, test automation code should be run and regression tests should be performed. In the staging environment, user acceptance testing should be done by the product team.

Smoke tests are a common test suite for all environments and they need to be run with each new release coming to the environments.

Once the code matures, performance tests can be performed before it is sent to production without any interruption in the system. When all tests are successful, the service should be served to the clients by making installations in the production on the product delivery dates.

The division of testing activities into different environments, from development to staging and finally production, ensures a systematic and controlled progression of the software. This approach not only allows for thorough testing of various aspects, including functionality, performance, and user acceptance but also enables quick bug identification and resolution.

Conclusion

Adopting a testing pyramid approach in the software development lifecycle is a strategic move for enhancing efficiency, reducing costs, and ensuring high-quality software. By implementing unit tests, integration tests, and end-to-end tests in a structured hierarchy, developers receive immediate feedback, and potential issues are identified and rectified as early as possible in the process.

By integrating automation into the testing process, repetitive and time-consuming tasks are handled efficiently, allowing teams to focus on critical aspects of software development. This results in a more reliable and robust software product that meets user expectations and minimizes the likelihood of issues in a production environment.

In summary, the ideal testing pyramid, combined with a well-defined testing environment strategy, contributes to creating high-quality software in an agile and efficient manner, ultimately benefiting both development teams and end-users.

--

--