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
The Quickcheck Javadoc is available 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);
Collections.sort(sorted);
return sorted;
}
}
More examples can be found in the here or in the assembly.
QuickCheck 0.6 March 19, 2011 Release notes
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:
If you are interested please send an email to blob79 at dev.java.net.