Follow The Test Pyramid
Before we deploy our software into production, it should be thoroughly tested. Testing ensures our program works as expected. End users are not thrilled about erratic and unexpected system behaviour.
Different types of program verifications are available to us; from unit tests to integration tests, system tests, and manual testing.
- Which of these is the most important?
- How much time and effort should we dedicate to each type of testing? I.e. How much of each testing should we do?
The Test Pyramid answers both questions.
The closer a test type is to the pyramid’s base, the more foundational and important it is. Thus, unit tests are critical in an optimal software testing strategy. Manual tests are the least important.
The Test Pyramid also shows the different tests’ approximate proportions: Numerous unit tests, fewer integration tests, some system tests, and a sprinkling of manual testing.
Unit Tests should make up the bulk of tests since we can automate them. They are fast to run, are finely-grained and robust. I have previously written on unit tests here, here and here.
The system should have Integration Tests verifying connections to databases, remotes services, and other externals. These are more fragile and much slower than unit tests. As a rule of thumb, we might end up with about a ten times fewer automated integration test than unit tests.
System or End-To-End Tests will be even smaller in number. These tests require a deployed and running production-like system. They are slow and break easily when test data, service configurations or network connections are misconfigured or flakey.
Lastly, we need Manual Testing for areas that are hard to write automated tests for, like the graphical user interface (GUI) or optimal customer experience (CX). Automatically testing whether a button has an attractive shade of blue or in the bottom right corner of the screen, is hard. People, on the other hand, are great at checking the UI.
The Test Pyramid encourages us to concentrate our efforts on verifying system correctness via automated, not manual, testing.
Today, the takeaway is that we should follow the Test Pyramid for an optimised testing strategy. In particular, favour unit testing over all other types of testing.
Leave a Reply
Want to join the discussion?Feel free to contribute!