Testing Pyramid - A Path To Achieve Efficient QA

Simplistic Testing Pyramid

You have a huge team of QA engineers but, there is still something missing in the way to reach the best performance. The tests are becoming time-consuming and whenever any setback is detected, the engineers get to rerun the whole process. If you are facing these issues, then the problem is that your QA team is acting without a proper strategy.

A step-by-step strategy tells you where you need to focus more, what you need, and how you should act there. Automating test cases may be beneficial but, you have to conduct manual tests also at some points. The testing devices, concentration points, and other parameters are different throughout the whole process. And, all these are determined by the test automation pyramid or the strategy to achieve a rock-solid QA.

What Is Test Automation?

We are going to focus on the testing pyramid but, first, we need to know what it is based upon. The process of running tests automatically, managing test data, and utilizing results to improve software quality is known as test automation.

This quality assurance measure significantly reduces the time and efforts of the entire software production team as the developers don't need to bother about preparing the test environment, running the tests, monitoring the results at every step, and keeping on making necessary changes.

After the test, the dev team can debug and improve the quality with a bigger plan. Also, test automation leads towards receiving faster feedback that helps in better debugging.

What Is Testing Pyramid?

The testing pyramid defines the type, frequency, and other parameters of the tests. And, based on that, the tests are categorized into three main categories. It also helps in clearly defining the roles and responsibilities of different team members so that, the issues that are causing the code to break are easily identified. Hence, the testing pyramid eventually helps in building a more reliable test suite that connects the whole team including technical and non-technical members.

It reduces the debugging time, ensures better quality, and increases the reliability of the application. Following the testing pyramid defines which tests should be automated and which ones should be manual. Also, testing according to the pyramid provides immediate feedback that exempts the existing features from breaking down.

According to the importance and execution process, the tests are categorized from bottom to top as follows -

  • Unit tests.
  • Integration tests.
  • UI / End-to-end exploratory tests.

The most automated layer of the pyramid is the lower layer (unit tests). Hence, the tests in this layer are faster than the other two layers. Then as we go upwards in the pyramid, both the number of tests and the speed decrease.

Every layer of the pyramid uses different sets of devices. The base layer or the most automated layer mostly uses virtual devices - emulators & simulators. The middle layer uses a combination of both virtual and real devices. And, the top layer mostly uses real devices. The use of different kinds of devices also affects the speed of the tests.

Usually, the team needs to conduct many small and isolated unit tests and the number of tests at the upper portion is fewer as the exploratory tests are mostly manual and time-consuming. The quick frontloading unit tests lead towards easier detection and fixing of the bugs whereas the later parts take more time.

Let's go through an overview of the three categories.

Unit Tests

We all know that the base of anything must be strong enough to let the upper portions stay steady. Similarly, the unit tests make sure that the individual components or functionalities work as expected in isolated conditions. Unit tests have a very small scope and consist of the scenarios like happy path, error handling, etc.

Besides being the strongest part of the pyramid, it is also the largest subset of it. It has a massive number of tests and that number increases with every feature being added. This means the addition of every new feature requires the test suite to run again.

These tests are dev-triggered and executed pre and post-commit. The immediate feedback of these tests has a huge impact on the developers' work.

As we can see this stage has the most number of tests and their feedback is very crucial, the unit-test suite must be fast-running. Practicing test-driven development (TDD) leads to building a robust unit test suite. In test-driven development, the test must be written before the code. Hence, the code turns out to be simpler, clearer, and bug-free.

For greater speed and efficiency in unit tests, they are mostly done on virtual devices - simulators and emulators. That way faster feedback is received. The commonly used frameworks are Java's Mockito and JavaScript's Sinon. They provide the developers with the ability to control the behavior of components used by the subject under testing.

Unit tests mostly focus on the smaller codebases. They do not deal with the parts that the users directly interact with. Hence, we must proceed towards the upper portions or tests that have involvement in the deployed application.

Integration Tests

As we saw that unit tests deal with small pieces of the codebase, they are not enough to ensure the quality of a codebase. That's why the integration tests at the middle layer of the pyramid come in.

These CI-triggered tests focus on how a small piece of code interacts with external components like databases, external services (API), etc.

These automated tests are not as frequent as unit testing. They check important operations like if the calls to databases or web services are properly handled. To run the planned operations smoothly, the software must communicate effectively and retrieve the correct information to function. For that, different types of tests should be conducted in different environments.

The efficiency of integration tests depends on the right balance between using real and virtual devices. While acceptance testing is better done in virtual devices, performance testing, security testing, and certain accessibility features require a mix of both real and virtual devices.

Also, the client usage analytics and market trends can make you add additional real device/OS configurations. However, as the real and virtual devices complement each other, you get the boost for achieving high-quality builds for nightly regressions.

As integration tests focus on the interaction with external services, these tests may run a bit slower depending on the preproduction environment. Also, to completely test the users' point of view, we cannot solely focus on integration tests. And, that makes us move towards the upper-most portion of the pyramid.

UI / End-to-end Exploratory Tests

It is the top layer of the pyramid and as the name “End-to-end exploratory” suggests, these tests are very complicated due to more dependencies than unit and integration tests. Though UI tests can be conducted faster with automation, exploratory testing is typically done manually making it time-consuming. Applications are tested from start to finish here to ensure that they are performing flawlessly.

In this stage of the test pyramid, the basic objective is to test how a user will interact with the application. That's why tests are mostly written from the users' perspective and mostly real devices are used. This helps the developers in debugging because users report their difficulties based on the experience from a real device.

This top step of the pyramid takes the longest to run and is very fragile because it depends on various parameters. Like integration tests, these tests may have to deal with external parameters like conflicting apps, call/text interruptions, network throttling, etc. Hence, it becomes critical to apply real user simulation to the tests.

As selenium provides a domain-specific language allowing developers to write tests that interact with a web app running inside the browser, Preflight lets you test the app as a user interacts with it. Explore our simplest browser extension to test your application.

Follow The Pyramid and Start Testing

Efficiency and better performance can never be achieved without a clear testing strategy. The testing pyramid ensures that:

  1. The easiest tests are done first and the complicated & time-consuming ones at the end.
  2. The process is streamlined and lets the testing team systematically enter the depth.
  3. It provides ease, efficiency, and speed to agile teams.

A wrong strategy can harm the product quality and make the team stuck with more work. Preflight provides you with the simplest infrastructure to test your application. Just add our extension to your browser and start testing your products without any involvement of coding. Check out our blog page for more interesting articles.