Chapter 6. Bulletproofing your code

 

This chapter covers

  • How functional programming affects program testing
  • Identifying challenges of testing imperative code
  • Testing functional code with QUnit
  • Exploring property-based testing with JSCheck
  • Measuring program complexity with Blanket

Good fences make good neighbors

Robert Frost, “Mending Wall”

Welcome to part 3 of this book. Having read parts 1 and 2, you’ll have noticed a central theme: functional programming makes your code easier to understand, read, and maintain. You can even say its declarative nature makes your code self-documented.

Now that you’ve written functional code, how do you prove that it works? In other words, how do you ensure that it meets the specifications laid out by your customers? The only way is to write code that tests whether the resulting behavior is as expected. Thinking functionally has a deep impact on application-level code and, through it, directly influences the way you design your tests.

6.1. Functional programming’s influence on unit tests

6.2. Challenges of testing imperative programs

6.3. Testing functional code

6.4. Capturing specifications with property-based testing

6.5. Measuring effectiveness through code coverage

6.6. Summary

sitemap