|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnz.ac.waikato.modeljunit.Tester
public abstract class Tester
An abstract superclass for all the test generation algorithms.
Each subclass must implement a generate()
method that
generates the next step in a test sequence.
Note that many test generation algorithms use randomness,
so this class provides a setter and getter for a random number
generator. By default this is set to new Random(FIXEDSEED)
,
so that test generation is deterministic.
Field Summary | |
---|---|
static long |
FIXEDSEED
|
protected Model |
model_
The model from which tests will be generated. |
protected java.util.Random |
rand_
A Random number generator for use in test generation. |
Constructor Summary | |
---|---|
Tester(FsmModel fsm)
A convenience constructor that puts a Model wrapper around an FsmModel. |
|
Tester(Model model)
Create a test generator for the given model. |
Method Summary | |
---|---|
CoverageMetric |
addCoverageMetric(CoverageMetric metric)
This is equivalent to addListener(metric), but more convenient. |
ModelListener |
addListener(ModelListener listener)
A convenience method that adds a listener object. |
ModelListener |
addListener(java.lang.String name)
A convenience method for adding known listeners and coverage metrics. |
void |
addListener(java.lang.String name,
ModelListener listen)
Deprecated. Use addListener(listener) instead. |
GraphListener |
buildGraph()
Equivalent to buildGraph(10000). |
GraphListener |
buildGraph(int maxSteps)
Equivalent to buildGraph(MaxSteps,true). |
GraphListener |
buildGraph(int maxSteps,
boolean clear)
Calls generate() repeatedly until the graph seems to be complete. |
GraphListener |
buildGraphBreadthFirst(int maxDepth,
boolean clear)
Generate a graph using a breadth-first approach with optimisations. |
abstract int |
generate()
Generate one more test step in the current sequence. |
void |
generate(int length)
Generate some test sequences, with the given total length. |
abstract java.lang.String |
getDescription()
A brief description of this test generation algorithm. |
Model |
getModel()
|
abstract java.lang.String |
getName()
The name of this test generation algorithm. |
java.util.Random |
getRandom()
Get the random number generator that is used for test generation. |
void |
printCoverage()
Prints the name and toString message from each coverage metric. |
void |
reset()
Performs a user-requested reset of the model. |
void |
setRandom(java.util.Random rand)
This allows you to specify a random number generator. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final long FIXEDSEED
protected Model model_
protected java.util.Random rand_
Constructor Detail |
---|
public Tester(Model model)
model
- Must be non-null.public Tester(FsmModel fsm)
fsm
- Must be non-null.Method Detail |
---|
public abstract java.lang.String getName()
public abstract java.lang.String getDescription()
public Model getModel()
public java.util.Random getRandom()
public void setRandom(java.util.Random rand)
rand
- A non-null instance of Random.public ModelListener addListener(java.lang.String name)
getModel().addListener(name)
.
See the Factory class for the set of known names.
name
- The name of a known listener.
public void addListener(java.lang.String name, ModelListener listen)
public CoverageMetric addCoverageMetric(CoverageMetric metric)
metric
- A non-null coverage metric to add.
public ModelListener addListener(ModelListener listener)
getModel().addListener(listener)
.
listener
- Must be non-null.
public void printCoverage()
public void reset()
public abstract int generate()
public void generate(int length)
length
- public GraphListener buildGraph()
public GraphListener buildGraph(int maxSteps)
public GraphListener buildGraph(int maxSteps, boolean clear)
generate()
repeatedly until the graph seems to be complete.
Note that this method uses a fresh random number generator
(with FIXEDSEED) to avoid modifying the random number
generator getRandom()
that is used for test generation.
maxSteps
- An upper bound on the number of calls to generate,
to avoid eternal exploration of large graphs.clear
- If this is true, the TODO and DONE flags on each
transition of the graph are cleared after the graph is built.
This is recommended, so that algorithms like GreedyTester
get a fresh view of the graph.GraphListener.isComplete()
public GraphListener buildGraphBreadthFirst(int maxDepth, boolean clear)
Note that this method uses a fresh random number generator
(with FIXEDSEED) to avoid modifying the random number
generator getRandom()
that is used for test generation.
The approach taken by this method is to maintain two queues:
maxDepth
.Note that this function is incomplete and will be available in a subsequent release.
maxDepth
- An upper bound on the depth to explore,
to avoid eternal exploration of large graphs.clear
- If this is true, the TODO and DONE flags on each
transition of the graph are cleared after the graph is built.
This is recommended, so that algorithms like GreedyTester
get a fresh view of the graph.GraphListener.isComplete()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |