This chapter covers
- Functional, unit, and integration testing in Haskell
- Property testing and how it’s applicable to common tasks
- Mocking for white-box testing
Testing is the last theme we’ll discuss to complete the methodology developed in this book. The software engineering discipline described various testing techniques a long time ago, but while this knowledge is considered mandatory, many code bases have not been tested appropriately. Previously, we named testability as one of the main characteristics of a good architecture. Given that we’re software architects, we cannot avoid learning about testing theory and practice.
Testing is part of the development process. Every professional developer writes tests, regardless of how many things are expressed by the type-level magic. Tests serve different purposes, such as fixating the contracts, preventing regressions, and providing documentation. Any software architect must think ahead about how to reduce project risks, and testing is one of the most important ways to do this.