Editorial Hi Clojurators,
Property-based testing (also known as Generative Testing) is gaining a lot of popularity. There are libraries in many major languages.
With Generative Testing, instead of writing a few test cases by hand, you automatically generate the test cases. Since it's automatic, you can generate a huge number of test cases randomly, and so cover a much larger space and find bugs you wouldn't find with a few hand-written cases.
Unit testing (written by hand) a function consists of two parts: the test case (the input to the function) and the expected return value. Well, imagine generating the input randomly. How do you know what the expected return is? That's hard, so let's try an easier problem. Instead of testing an expected value, you could test some known property of the value, for instance that it's a positive integer. Or more complex, like the return value is negative if the input is negative. It can get very much more sophisticated.
It turns out that generative testing finds more bugs than hand-written unit tests, and can even give a minimal input that makes the test fail. I've been researching generative testing and also using it in production code. I though I'd share some of the resources I have found useful.
Enjoy the issue!
Eric Normand <email@example.com> @ericnormand
PS Learn more about the Clojure Gazette and subscribe. Learn about advertising in the Gazette.