The importance of the Test Pyramid for software quality

by Rodrigo Pinto

The importance of the Test Pyramid for software quality

by Rodrigo Pinto

by Rodrigo Pinto

The leftover risotto is a great analogy to explain in a didactic way the relevance of the test pyramid to stakeholders

By Rodrigo Matola
It is sometimes difficult for a non-technical stakeholder to understand the importance of testing a functionality well before putting the application into production. I always heard: “I understand the importance of the Test Pyramid, but I need to release this at the end of the next Sprint. If unit tests are going to take longer to deliver, they are not a priority”. With that, I thought of some analogies to explain the test pyramid and its importance during the development of a digital product. Let’s talk now about the “leftover risotto”!

How to make a leftover risotto

I remember very well the risotto that my mother and aunts prepared the day after some party, especially at the end of the year, at my deceased grandmother’s house, with the leftovers. I liked it even more when the risotto was in the oven. However, making this risotto is quite simple. With the help of at least two more people to form a team of 3 and optimize the process. You can call more if you want, but it is recommended that the team does not exceed 9 people. Follow these instructions: – Make a new rice cooker and mix it with the leftover rice (which is not enough for everyone to eat); – Take leftover pork, turkey, chester, tender and all other available. Shred and mix in rice; – Take all other leftovers, chop into small pieces. Mix in the previous mixture; – Place grated Parmesan cheese on top and bake until browned. Now let’s start the analogies…

Putting into production

When serving the risotto, each person at the table “downloads” for their plate. Then the complaints begin: “It tastes sour”; “This is ruined!”; “I found it sweet”; “Candy? My part was extremely salty!”. Each person reports a different bug . You will have to throw the risotto away and you took a big loss, since you will have to order food for the whole family now it will be expensive… But first, as a stakeholder, you want to find out what went wrong. But how do you find out what’s wrong with this whole mix?

Applying the Test Pyramid

Returning to the development of digital products, after the analogy mentioned above, we can understand how important the testing process is to guarantee the quality of the final product. For this, we can list:

Unit tests

Going back in time, to the moment of the team’s assembly, in order to prevent the previously mentioned occurrence from happening, each member of your team should taste the ingredient before putting it in the risotto. The unit test of each item must be performed first. These tests would show that the rice that was left out of the fridge would be sour and that the pork was spoiled, for example. The unit tests serve precisely to test the smallest part of a system. In risotto, I would test if each ingredient was good to add. In a code, each unit (function, object, among others) is tested and is behaving and responding as it should in various scenarios.

Integration Tests

Even if each unit is ready and according to the specifications passed, it is also necessary to check if, when placed together, they match, that is, integrate. Returning to the leftover risotto analogy, let’s first take the complaint that “the risotto was too salty”. It is necessary to go testing the amount of salt until it is ideal. Although the salt passed the unit validity testand the integration testit returned a value much higher than expected, which “broke” the risotto. As for the very sweet complaint, it was asked to add black olives. But, the person who was in charge of this part did not know the business well and added raisins. The unit test passed, although it was developed wrongly, but the integration test would not pass. In this case, the unit test must be redone.

Functional and exploratory tests

Even if black olives integrate well with rice, for example, it might not “work” if you mix another ingredient together. At each increment of the risotto (software) it is necessary to test if it is “working” as expected. If someone decides to put nuts or peanuts in the risotto simply because they like it, even though it works and looks good, other guests may not like it or have allergies. In the software world, it may be that someone has made an implementation different from what was in the specification or even invents one. With the functional tests it is possible to identify this. As an extension, if someone missed a piece of bone, only an exploratory test would detect it. In this case, the error would be in a specific part of the risotto (code) that only a user at the table (production) would find.

Regression Tests

We must also “test” (prove) the risotto with each implementation. When adding salt, test to see if it is salty. Test the consistency of the rice to see if you need more water and cook more. And add the salt and water little by little. If you add a fixed amount of these ingredients, it can get salty, turn into soup or go raw. Bringing this example to software development, test it thoroughly with each new implementation. And don’t do gigantic implementations, like putting the final amount of salt and water together, for example. Make small and constant releases, of only one feature, because if something goes wrong, it’s easier to fix.

Acceptance Tests

Finally, tests must be carried out on the complete product before serving. It is not advisable for a single person to test, even if they have detailed specifications, as the final product will be consumed by several people. The more people taste (test), the more quality your final product will have! In the case of risotto, it is not feasible to carry out an automated test (using a chemical analysis, for example). Tests have to be manual and exploratory, but in the case of software, tests can (and should) be automated, leaving manuals for scenarios that aren’t worth the automation effort.

Conclusion

This leftover risotto example is a different way we used to explain the test pyramid to people without a programming background, the importance of splitting and, most importantly, testing during the development cycle and not just at the end. Testing every element of a digital product before offering it to the public can actually take a little longer. However, it ensures that the product has a better quality and that the end customers are more satisfied. Did you like the text? Have questions about the test automation process? Leave your comment here! You still have questions about how to implement these tests, make a chat with us, we can help you!   Why are Agile processes not helping in Digital Transformation?
Compartilhe com seus amigos!
Top