QuickCheck-style ParameterSuppliers for JUnit

QuickCheck is a neat Haskell tool for specifying properties that should hold for functions and firing lots of random inputs into those functions to test that the properties hold true. JUnit's answer to such properties is the notion of "theories." Using some annotations and ParameterSuppliers, it should be possible to generate some number of random values for theory parameters. To test this out, I've started a project on GitHub called junit-quickcheck. It's rather embryonic at this point, but I hope to grow it into something lots of people can benefit from.

A quick example:

    public class AbsoluteValue {
        // fire 100 random ints at the theory
        public void isAdditiveInverse(@ForAll int i) {
            assumeThat(i, lessThan(0));
            assertEquals(-i, Math.abs(i));

What about remembering previously successful/failed values? Restricting/broadened sample size? So many possibilities...

Written on October 18, 2010