15 Testing

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.

15.1 Testing in functional programming

15.1.1 Testing basics

15.1.2 Property-based testing

15.1.3 Property-based testing of a free monadic scenario

15.1.4 Integration testing

15.1.5 Acceptance testing

15.2 Advanced testing techniques

15.2.1 Testable architecture

15.2.2 Mocking with free monads

15.2.3 White-box unit testing

15.2.4 Testing framework

15.2.5 Testability of different approaches

Summary