8 Property-based testing

This chapter covers

  • Verifying properties of APIs
  • Developing a property-based testing library

In chapter 7, we worked through the design of a functional library for expressing parallel computations. There we introduced the idea that an API should form an algebra—that is, a collection of data types, functions over these data types, and, importantly, laws or properties that express relationships between these functions. We also hinted at the idea that it might be possible to somehow check these laws automatically.

This chapter takes us toward a simple but powerful library for property-based testing. The general idea of such a library is decoupling the specification of program behavior from the creation of test cases. ...

Get Functional Programming in Scala, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.