Skip to main content
This revision made April 29, 2011 10:59, by blob79


QuickCheck is an implementation of the Haskell QuickCheck specification based test tool.

The goal of QuickCheck is to replace scenario-based testing with specification-based testing. A QuickCheck-based test tries to cover the laws of a domain whereas classical scenario-based testing can only test the validity for heuristically (manually) picked values. In the absence of tools that could confirm the compliance to a specification (like compilers can confirm the validity of source code for a type system) QuickCheck tests the specification with generated values.

Basically QuickCheck is about generators of data. The QuickCheck runner method is just a fancy for loop implementation. QuickCheck can help in scenarios where whole classes of test cases have to be tested and it is not feasible to write tests for all distinct test scenarios.

Generators supported for

  • types (primitive: int, byte, long, String, char, null, boolean; collections: arrays, lists; POJOs)
  • value ranges (integer, chars)
  • lists, sets and array
  • distinct values (uniqueValues, ensureValues, fixedValues, enumValues, clonedValues, excludeValues)
  • distributions
  • generator strategies (composition of generator values (oneOf, frequency, list, array, nullsAnd), transformation, mutation)
  • value frequencies (frequency, oneOf)
  • determinism (random, deterministic )



The Quickcheck Javadoc is available class="del">overv</span>ndiew-summaryx.html here.




The following example test that a sorted list implementation is actual sorted. The values inserted into the list are arbitrary integer values.

public class SortedListTest {

   @Test public void sortedListCreation() {
      for (List<Integer> any : someLists(integers())) {
         SortedList sortedList = new SortedList(any);
         List<Integer> expected = sort(any);
         assertEquals(expected, sortedList.toList());
  private List<Integer> sort(List<Integer> any) {
      ArrayList<Integer> sorted = new ArrayList<Integer>(any);
      return sorted;
More examples can be found in the here or in the assembly.


QuickCheck 0.6 March 19, 2011

QuickCheck 0.5.1 February 17, 2011

QuickCheck 0.5 January 2, 2010 Release notes

QuickCheck 0.4 June 3, 2009

QuickCheck 0.3 March 23, 2008

QuickCheck 0.2 July 23, 2007

QuickCheck 0.1 July 7, 2007


Project QuickCheck needs help in the following areas:

  • Todos
  • Sample code.
    • The test code in Robert C. Martin's Clean Code offers plenty of opportunities to show Quickheck's strengths.
    • One possibility is to port the code from Alberto Savoia's Beautiful code chapter Beautiful Tests and make it beautiful with

If you are interested please send an email to blob79 at

Difference compared to previous revision
<span> ===API=== The Quickcheck Javadoc is available [<span style="text-decoration:underline;color:green"><span class="del"></span>overv<span style="text-decoration:underline;color:green"></span><span class="add">nd</span></span>ie<span style="text-decoration:underline;color:green"><span class="del"></span>w-summary<span style="text-decoration:underline;color:green"></span><span class="add">x</span></span>.html here]. ===Introduction=== <span>
Please Confirm