Testing Pyramid

Mike Cohon’s Test Pyramid

Among the software community, Testing Pyramid is a very well-known pattern. At the same time, many couldn’t follow this pattern (or follow the Ice-cream cone anti-pattern). The pyramid highlights two facts,

  • Grouping the tests
  • Fewer slower tests

The benefits of this model are

  1. Faster feedback loops
  2. Cheaper cost to fix bugs

What is a feedback loop?

A feedback loop is a process by which you get feedback about a code change. The feedback can be positive or negative(bug).

How to make the feedback loop faster?

The answer is Automation.

With the evolution of test automation tools, automation can be achievable. Automation becomes a core part of any organisation as it will speed up the process of release. With the enablement of automation and DevOps, teams are able to release a change within hours compared to monthly and quarterly releases in the past.

You can say that Mike Cohon’s test pyramid doesn’t suit current or modern architectures. But, it does so by simplifying the groups. Let’s look at the pyramid at a more granular level.

More granular level Test Pyramid

As you can see more granular groups in the updated pyramid. To know more about these groups refer to this blog

The shape is as important as the grouping. The ordering of these groups simply follows one rule which is more fast tests and a small number of slow tests. You can achieve this by following certain rules,

  1. Statergise your approach
  2. Keep an open-mind interms of reviewing the tests(remove and add tests)
  3. Ready to challenge whether a test can move down the pyramid
  4. Use effective mocking tools

There is been recent suggestions on altering the pyramid to a honeycomb model to adopt to microservice architecture. The honeycomb model suggests that we need to have more integration tests than the unit and end-to-end tests. But, given the introduction of contract tests, we can eliminate the need for more integration tests as it is slower compared to contract tests.

Leave a comment