When writing software these days, it is common to also write tests. One of the main reasons for writing tests is to verify that the code works when you write it and that the code still works after making changes later on. You write tests to build confidence that a change does not negatively impact the quality of the code and that the software is ready for deployment into production.
The same applies to testing Infrastructure as Code. When you’re talking about writing software tests, you might be introduced to what is called the test pyramid. It describes various forms of testing and shows that each has its pros and cons. The layers within this pyramid can differ from application to application, depending on how you build yours. A simple example is shown in figure 9.1. In this pyramid, you see three layers: unit tests, integration tests, and UI tests. You could have more layers in your scenario; for example, you might add performance testing.