Automated testing Flashcards
Randoop
feedback directed
random testing. It is suited for unit testing of Java program fragments like
classes and libraries.
Leveraging types
Consider this remove method in Java, for instance. It takes two arguments: a binary
tree and a node to remove from the tree.
Leveraging invariants
The repOK function takes as input a BinaryTree object bt, and
returns true if it is a valid binary tree, and false otherwise.
to be a valid binary tree, it should
satisfy one of two different cases:
the root may be null
if the root is not null, then the structure should be a directed tree. That is:
It should have no cycles
Every node except the root should have one parent
And the root should have no parent
Leveraging pre and post conditions
Going even further, the programmer can specify pre and post conditions, denoted in
our example program via requires and ensures annotations, respectively. In this case,
the pre-condition states that the input node n must be contained in the input binary
tree bt. Such a pre-condition could further prune the space of candidate inputs by
avoiding generating inputs where the node n is not contained in the binary tree bt.
Furthermore, the post-condition could be used to check that the remove method
indeed removes the given node from the given binary tree, on each generated test
input. You should by now have a good sense of how far specifications can go in
helping to guide test generation.
Randoop’s input
Randoop’s input consists of three things:
a set of classes making up the library under test,
a time limit that allows the user to control how many tests Randoop generates, and
a set of contracts, which are properties that the object generated in the final call of a
Randoop-generated test is required to satisfy.