Testing Automation, What are Pyramids and Diamonds?
Testing pyramids (which are also referred to as Test Automation pyramids) is a framework that lays out the different types of tests that should be included in automated test suites. Producing high-quality software and reducing the time required to identify breaking change is not a trivial task. The testing strategy is a very important factor in deciding the agility of your team and project.
Why Testing Pyramids are important?
- Quality of the product: A product free of defects and issues.
- The velocity of the team: How fast a feature could be delivered.
- Release predictability: The ability to plan and deliver with predictability.
What are different Types of Pyramids?
Testing Pyramid
You might have probably seen the test automation pyramid something like above by now. Mike Cohn came up with this concept in his book Succeeding with Agile. It tells us about different testing layers and how much testing is required to be done on each layer. The different Layers are:
- Manual Testing: We should have a test suite strong enough to avoid any manual testing which is required as a prerequisite before taking it to production. But in the practical world, there are times where we cannot completely avoid manual testing due to time or delivery constraints. We should introduce tests as early as possible to maintain hygiene. If it is practice, then it highlights something is wrong with how we are testing.
- End To End Testing: Automated tests, which are responsible for testing applications workflow from beginning to end for the entire software. They focus on testing user stories or an end to end functionality that simulates real-world scenarios. In a microservices architecture, it can span across different services to test a functionality End To End.
- Integration Testing: It takes different software modules that are integrated logically and test them as a group. In microservices architecture. It can also refer to testing service in isolation.
- Unit Testing: Unit tests take a small piece of the product and test that piece in isolation.
Inverted Test Pyramid
The Inverted test pyramid which is also referred to as Ice cream cone pyramid is another strategy in which a lot of focus is made towards Manual/E2E Testing and is least concerned about Unit Testing. The cost of testing is too high and are extremely painful and inefficient. It impacts agility and is sometimes considered as an Anti Pattern that should be avoided.
But, it works well when you are developing application prototypes or working on Proof of Concept, where the focus is more on developing a functionality rather than investing time in maintaining Test Suite. Prototypes eventually phase out to stable products.
Diamond
We all know that writing and maintaining a test suite is not cheap. Like source code, it should be carefully written and maintained. In the microservice world, practically speaking Integration Tests could hold more value than Unit tests. Testing how an application behaves when it interacts with other services provides more confidence and reliability on the test suite. Integration test does not mean to test application using actual service, rather mocks should represent external service so that tests run in isolation.
End to End Tests is still hard to develop and maintain and should be avoided.
How to apply them in projects?
Comparison on different Metrics
Final Thoughts
The true value of the test strategy is to let the developer know that there is some problem with code changes, the issue lies in what area and how fast we can get to know about the problem. There is no right or wrong strategy, It’s all about what works for you.
Please share your thoughts and experiences.
References
- https://www.linkedin.com/pulse/inverting-test-pyramid-joel-masset/
- https://martinfowler.com/bliki/TestPyramid.html
- https://martinfowler.com/articles/practical-test-pyramid.html
- https://eason.blog/posts/2020/03/test-automation-diamond/
- https://testing.googleblog.com/2015/04/just-say-no-to-more-end-to-end-tests.html
- https://engineering.atspotify.com/2018/01/11/testing-of-microservices/