The Testing Pyramid
Software should be tested to its full capacity before being released to its end users in a production environment. To try to get the best testing coverage, different levels of testing should be performed. It is unlikely to catch every bug before releasing an application to production, but the job of testing is to limit the number of bugs that do get through. The different layers of the testing pyramid include unit testing, integration testing, and system/end-to-end testing.
This article will cover:
- Structure
- Who Creates The Tests
- Effectiveness
Structure
The lower on the pyramid the tests are, the cheaper and easier they are to create and run. For example, a unit test should be testing just a method or function. Whereas a system test may be creating a user, calling several different methods, and then querying a database. Because of this, as we go up the testing pyramid, the tests also become slower and take longer to run. A unit test may take 3 seconds to execute, whereas a system test may take a couple of minutes depending on what all it is testing.
The split can be roughly 70–20–10. So for every 70 unit test, you can aim to have 20 integration tests and 10 system/end to end tests. These numbers are not concrete, just a guide to aim for. Unit tests…