The Importance of Testing Pyramid

Anand Varne
2 min readSep 28, 2021

--

In this agile world, developers are rapidly developing code and creating valuable applications. Continuous Integration is a development practice where developers frequently integrate code into a shared repository, preferably several times a day. Integration can then be verified by an automated build and automated tests.

Before jump into Continuous Integration first, we need to see the importance of testing.

The testing pyramid is a way of thinking about how different kinds of automated tests should be used to create a balanced portfolio.

y project repository should follow the practice to write Unit Cases for the APIs.

Unit tests take a small piece of the product and test that piece in isolation

Unit tests are fast. We only need to build a small unit to test it, and the tests also tend to be rather small. One-tenth of a second is considered slow for unit tests.

Unit tests are reliable. Simple systems and small units, in general, tend to suffer much less from flakiness. Furthermore, best practices for unit testing — in particular practices related to hermetic tests — will remove flakiness entirely.

Unit tests isolate failures. Even if a product contains millions of lines of code, if a unit test fails, you only need to search that small unit under test to find the bug.

Unit tests do have one major disadvantage even if the units work well in isolation, you do not know if they work well together. Integration test / Service API layer test comes into the picture after completing Unit Testing.

An integration test takes a small group of units, often two units, and tests their behavior as a whole, verifying that they coherently work together.

Once code Unit and Integration testings’ are done, we can say that the business logic we have written for the application is working as expected because major code is covered with these 2 testing cycles. Now the output that we are expecting needs to be rendered on UI properly. Here comes Functional Testing/ UI Testing comes into the picture.

Functional tests are costly as compare with Unit tests. It also takes more execution time than Unit and Service layer tests. Hence the more we write Unit cases, the less chance of any bug found in production.

--

--

Anand Varne

DevOps enthusiastic | DevOps Lead | GitOps | CI / CD | Process Automation | Developer | Git | Jenkins | Docker | Ubuntu | Shell / Bash