12 Testing functional programs

In this chapter you will learn

  • how to test pure functions by providing examples
  • how to test pure functions by providing properties
  • how to test side effects without using any mocking libraries
  • how to develop new functionalities in a test-driven way

Beware of bugs in the above code; I have only proved it correct, not tried it.

—Donald Knuth

Do you have tests for that?

This last chapter of the book is devoted to one of the most important software engineering activities: testing. Tests are one of the major methods of writing maintainable software. They can be used to make sure the program behaves according to the requirements, it doesn’t have bugs we discovered earlier, and that it integrates with external APIs, ...

Get Grokking Functional Programming 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.