ANN: junit-quickcheck 0.2

"Paul Holser" <[email protected]> Mon, 29 Jul 2013 21:53:38 -0000
Newsgroups gmane.comp.java.junit.user
Message-ID <[email protected]>
I've released junit-quickcheck 0.2 to Maven central. junit-quickcheck leverages the ParameterSupplier capability of the JUnit Theories runner to invoke theory methods with lots of different random values. This way you needn't bake DataPoints into your theory classes (unless you want to constrain the checking to a fixed, known set of values).

junit-quickcheck uses a version of the JUnit Theories runner that respects generics (mostly) on theory parameters. So, a theory parameter of type List<String> will really get fed lists of Strings, and you can't sneak in a List<Integer> instead. This Theories runner lives at http://github.com/junit-team/junit.contrib, in the "theories" subtree. It too is released to Maven central:

    <dependency>
        <groupId>org.junit.contrib</groupId>
        <artifactId>junit-theories</artifactId>
        <version>4.11</version>
    </dependency>

The big change in version 0.2 is that the generators for Java primitives, collections, etc. are packaged in a separate ServiceLoader'ed JAR file. You'll want both junit-quickcheck-core-[version].jar and junit-quickcheck-generators-[version].jar on your class path.

As the 0.2 versioning would indicate, the "language" of configuring generation of random values for theory parameters is rather basic. I'm hoping you'll try this out and give feedback about what you think is missing.

If you'd like to do property-based testing the JUnit way, give this a try and let me know what you think.

Thanks!

Regards,
Paul Holser