The key point of John Hughes's speech was: "Don't write tests, generate them".

Through expressive examples he highlighted the importance of having proper and extensive tests for your application. The problem with manually written tests is that even by eliminating most of the unnecessary state from your software (like by using functional programming), you can never prepare for every possible input. You can even easily miss the ones that create unexpected behavior by saying they could never happen. They can.

By generating you tests, you still cannot be sure you covered every possible cases where it might go wrong, but you can significantly increase your level of confidence you did.

Advertisement

The problem with generated tests is that they create too much noise to easily find the combination of inputs that lead to the unexpected behavior. This is where QuickCheck kicks in: it finds you the minimal set of inputs that brings your system into the faulty state. It helps you focus on what you need to fix rather than how you can trigger the failure in the first place.

QuickCheck is also a great tool to find concurrency problems. Since you normally think of the sequential execution of your program and set up your manual tests according to that, you can easily miss testing how your code behaves in a concurrent environment. By generating your tests, that can easily and naturally be overcome.

Advertisement

According to Hughes, QuickCheck is currently able to test Haskell and C programs out of the box. For Scala and Java, ScalaCheck is out there, that is claimed to be inspired by QuickCheck. Stay tuned for a post about how concurrency problems can be detected using Scala and ScalaCheck.