 |
QuickCheck is an implementation of the Haskell QuickCheck specification based test tool. Each specification is tested 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.
(E.g.: "This algorithm has to work for unicode string values of unlimited size.")
Generators support different:
- types (primitive: int, byte, long, String, char, null, boolean; collections: arrays, lists; POJOS)
- value ranges (integer, chars)
- distinct values (uniqueValues, ensureValues, fixedValues, enumValues, clonedValues)
- sizes (String, Lists, Arrays)
- distributions
- generator strategies (composition of generator values (oneOf, frequency, list, array, nullsAnd), transformation, mutation)
- value frequencies (frequency, oneOf)
- determinism (random, deterministic )
Javadoc
The current javadoc can be found here.
Example
The following example asserts 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;
}
}
Releases
Quickcheck 0.4 June 3, 2009
Quickcheck 0.3 March 23, 2008
Quickcheck 0.2 July 23, 2007
Quickcheck 0.1 July 7, 2007
Snapshots
QuickCheck 0.5. snapshot November 4, 2009
QuickCheck 0.4. snapshot November 23, 2008
QuickCheck 0.3. snapshot March 21, 2008
QuickCheck 0.2. snapshot July 15, 2007
Blog
Blog
Help
Project QuickCheck needs help in the following areas:
- General development help.
- Sample code.
- Documentation.
If you are interested please send an email to blob79 at dev.java.net.
|