The Evolution of the Testing Pyramid
As software testers, we've all heard about the Testing Pyramid. In my opinion, there's a misunderstanding in how we should apply the Testing Pyramid in our projects.
Join the DZone community and get the full member experience.Join For Free
As software testers, we've all heard about the Testing Pyramid. However, in my opinion (and in the opinion of others), there's a misunderstanding in how we should apply the Testing Pyramid in our projects.
If you have never heard about the Testing Pyramid I recommend you read these posts in this sequence (believe me, doing this will help you understand this post better):
Now, it's time for some critical thinking.
Question: When we see a model, what is the first thing that we do?
Answer: Follow it!
Let’s be honest with ourselves: we follow the model without question (in most of the cases). But have you realizes that the Testing Pyramod is a model and a analogy?
The first post that I referred to says:
Remember that this is just a model, it is not a hard-and-fast rule that should be adhered to in every software project. (James Willet)
Many people try to use the Testing Pyramid like a hard-and-fast rule, believing that all of the tests should be pushing to the base of the pyramid because we need fewer and fewer tests in the UI. I disagree.
After reading all these posts and concepts, do you agree with me that a strategy for testing automation is more like a Testing Geometrics than a Testing Pyramid?
Obviously, we have a lot of geometric shapes: pyramid, pentagon, rectangle, star, ellipse, and so on (try to google geometric shapes).
Now, consider the following in that mindset:
In a scenario in which you need to test a mobile app, the focus will be the user interface, correct? However, if you keep thinking that the Test Pyramid is a rule, you cannot focus (and put more tests than the other layers) in the UI layer. No, you can put however many tests you find necessary!
When we test a mobile app, at least three layers need to be tested: unit, services, and UI (this fits perfectly in the first Test Pyramid). However, if you miss a bug in the UI layer in production, what do you think is the first thing that the user will do? Obviously, it's not reporting the bug; it's a complete uninstallation of your app! (And the user, probably, will never return or install it again.)
So, wich geometric shape can you use to focus more on the UI layer? I say a cylinder because all of the tests in these three levels are important.
In a scenario in which you need to test microservices, the focus will be the unit tests, correct?
Again, if you keep thinking that the Testing Pyramid is a rule, you cannot focus (and cannot put more tests) in the Service layer.
If you are building a microservices, the UI layer is missing, and you will focus on the unit tests. However, the services are the heart of this. You must test them! Remember, you need to test all of the services.
So, wich geometric shape can you use to focus? I should say a star!
"But Elias, a star?" Yes!
You'll do some unit tests, but (in my opinion) the services test will have more focus. You need to integrate each service in another test or suite in order to guarantee the sanity of this integration.
How About You?
Do you agree with this concept? Let me know in the comments below.
Published at DZone with permission of Elias Nogueira. See the original article here.
Opinions expressed by DZone contributors are their own.