Is the ice cream testing via the Inverted test pyramid an anti pattern?

141    Asked by AnilJha in QA Testing , Asked on Apr 26, 2022

 I know that the inverted test pyramid, i.e., having more end-to-end tests than unit tests is an anti-pattern.


However, I've started to think, what could be the advantage of having less unit tests then tests of higher levels, black box tests, talking to a tested component through some API/protocol, e.g. (SOAP, REST, etc.).


The only advantage I’ve found is when I migrate the component from one language to another but preserve the same component API/protocol.


In such a case, having high test coverage for API gives me much confidence that the migration went fine. Unit tests do not give this confidence, because they are tightly bound to the programming language, and when I migrate the code under tests from one language to another, I need to migrate unit tests, which means the possibility to introduce bugs to unit tests as well. Plus more effort.

Any other advantages of having more integration tests than unit tests?

Answered by Anisha Dalal

Yes and No


More often than not, an inverted pyramid (ice cream testing) is an anti-pattern, but there are circumstances where it is not. Your example of needing to rebuild an API in a different language is one such example. Some other circumstances where you might want to invert the pyramid include: You have an integration to a third party API. Your lowest level tests are really there to ensure that the API hasn't changed on you. Most of your tests are going to be end-to-end to make sure your application correctly formats data for the API and correctly handles responses from the API.

You have an integration to a specialized physical device. The same basic principles apply, except that a lot of the end-to-end testing is likely to be manual because specialized devices (like turnstiles, RFID-managed lockers, etc.) are not good candidates for automation and simulators will not necessarily give completely accurate responses.

You are testing communication between different applications/systems/apis. If your primary focus is the communication between the different systems, then the pyramid will be inverted. You are working with legacy code. If you are working with legacy code, there may not be a choice in how you automate. Any stable legacy system is likely to have UI and processing logic tightly intertwined, making unit testing a challenging exercise if not impossible.



Your Answer

Interviews

Parent Categories