In this blog, we aim to briefly explore the agile testing pyramid. So, let’s get going. Here, we will get acquainted with the following topics by the end of this blog
- What a testing pyramid, an overview?
- Types of test Pyramid
- Unit Tests
- Service Tests
- UI Tests
What is the testing pyramid?
The agile test automation pyramid is a graphical strategy guide for implementing test automation. According to Martin Fowler, a world-renowned software developer,
“The “Test Pyramid” is a metaphor that tells us to group software tests into buckets of different granularity. It also gives an idea of how many tests we should have in each of these groups. Although the concept of the Test Pyramid has been around for a while, teams still struggle to put it into practice properly“
The Test Pyramid.
If we are to automate the test cases efficiently and according to the best practises, we would have to be familiar with the concept of the test pyramid. Initially, Mike Cohn came up with this concept in his book “Succeeding with Agile”. This concept gives an idea of the testing layers and how much testing is required on each layer.
The layers are (bottom to top):-
- Unit Tests
- Service Tests
- User Interface Tests
1st layer: Unit Tests
Clearly, in the pyramid, most of the testing should take place in the development stage. These tests are the easiest, cheapest, and fastest to complete and are an important aspect of test-driven development. Running more test at the initial phase enables us to check our work as we develop, Therefore, getting tested done immediately allows us to spot bugs and their life here is also very less as they are difficult to hide at this level. The bugs that have gone to production or higher environment, especially in terms of UI testing, have a long lifespan as compared to these and they put up a bigger fight as well we try to get rid of them.
2nd layer: Service /Integration /Component Tests
After we run all of the unit tests and they pass, we can move onto the API/ integration/ component testing phase. An integration test is conducted to ensure that all the features that have been developed are running smoothly with each other. This the layer where we can test most of the logic and check whether business needs are being fulfilled or not, without going through the UI.
If you have to decide whether to automate at this level or the UI level, we would have an upper hand here as there will e fewer problems, easier maintenance and faster test execution. Hence the overall advantage to automate here is we will be able to find the bugs sooner and thus their lifespan will automatically get reduced. These tests are much slower and complex than the test at the base layer, i.e, unit tests, however, these are much faster and less complex compared to the UI tests.
3rd layer: User Interface tests
Last and run least are UI tests. It’s best to run them less frequently as they are costly, more difficult to prepare and take a long time. Here we just want to make sure that the end-user experience with our product should be good and it is working as per the expectations. It is recommended that we should automate only the critical test. For example, the user flows staring from login to the final act of the user such as making payment. When we running the UI tests, manual and exploratory testing can be conducted as well as shown in the sphere shape above the pyramid.
In conclusion, the pyramid approach is a much stronger, beneficial and cost-reducing approach. Rather than putting the focus on automating GUI tests and following the “ice cream cone anti-pattern.” as shown in the image above.
In order to do efficient testing according to the best practices, it is vital to adopt the approach of the agile testing pyramid.