|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnz.ac.waikato.modeljunit.Tester
nz.ac.waikato.modeljunit.LookaheadTester
public class LookaheadTester
A test generator that looks N-levels ahead in the graph. It chooses the highest-valued transition (action) that is enabled in the current state. The value of transitions/actions and states is determined by three parameters, NEWTRANS, NEWACTION and DEPTH. In a given state, the value of an action that has never been taken before in that state (so its destination state is unknown) is NEWACTION if its action has never been taken anywhere in the graph, or NEWTRANS if its action has been taken elsewhere. The value of an action that has been taken before is the value of the state that it leads to (*), minus the number of times that the transition has been taken. So previously-taken paths gradually become less and less attractive. (*) if the action is non-deterministic, then there are several transitions labelled with that action, and the value of the action is the maximum of the value of those transitions. The value of a state is zero if it is the current state, or if it is at least DEPTH steps away from the current state, otherwise it is the maximum value of its outgoing transitions. This means that the lookahead is limited to paths of length DEPTH. The get/setMaxLength methods can be used to control the maximum length of each generated test. If the test generation has not reached a terminal state before that length, it does a reset.
Field Summary | |
---|---|
protected CoverageMetric |
actions_
|
protected int |
currLength_
The length of the current test sequence generated by this tester. |
protected int |
DEPTH
How far should we look ahead? |
protected GraphListener |
graph_
|
protected int |
maxLength_
The maximum length of each generated test |
protected int |
NEW_ACTION
How worthwhile is it to use a completely new action? |
protected int |
NEW_TRANS
How worthwhile is it to explore a new transition? |
protected CoverageMetric |
transitions_
|
Fields inherited from class nz.ac.waikato.modeljunit.Tester |
---|
FIXEDSEED, model_, rand_ |
Constructor Summary | |
---|---|
LookaheadTester(FsmModel fsm)
A convenience constructor that puts a Model wrapper around an FsmModel. |
|
LookaheadTester(Model model)
Creates a test generator that can does smart look ahead. |
Method Summary | |
---|---|
int |
evalState(java.lang.Object state,
int depth)
Evaluate the desirability of reaching state . |
int |
generate()
Generate one more test step in the current sequence. |
int |
getDepth()
|
java.lang.String |
getDescription()
A brief description of this test generation algorithm. |
int |
getMaxLength()
The maximum length of each generated test. |
java.lang.String |
getName()
The name of this test generation algorithm. |
int |
getNewActionValue()
|
int |
getNewTransValue()
|
static void |
main(java.lang.String[] args)
|
void |
reset()
Performs a user-requested reset of the model. |
void |
setDepth(int depth)
Set the lookahead depth. |
void |
setMaxLength(int maxLength)
Set the maximum length of each generated test. |
void |
setNewActionValue(int value)
Set the NEW_ACTION parameter. |
void |
setNewTransValue(int value)
Set the NEW_TRANS parameter. |
Methods inherited from class nz.ac.waikato.modeljunit.Tester |
---|
addCoverageMetric, addListener, addListener, addListener, buildGraph, buildGraph, buildGraph, buildGraphBreadthFirst, generate, getModel, getRandom, printCoverage, setRandom |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected int NEW_TRANS
protected int NEW_ACTION
protected int DEPTH
protected int maxLength_
protected int currLength_
protected GraphListener graph_
protected CoverageMetric transitions_
protected CoverageMetric actions_
Constructor Detail |
---|
public LookaheadTester(Model model)
model
- Must be non-null;public LookaheadTester(FsmModel fsm)
fsm
- Must be non-null.Method Detail |
---|
public int getDepth()
public void setDepth(int depth)
depth
- the depth of the recursive lookahead (1..n)
This should be reasonably small, otherwise the lookahead
may be exponentially slow. The default value is 3.public int getNewActionValue()
public void setNewActionValue(int value)
value
- public int getNewTransValue()
public void setNewTransValue(int value)
value
- public int getMaxLength()
public void setMaxLength(int maxLength)
public java.lang.String getName()
Tester
getName
in class Tester
public java.lang.String getDescription()
Tester
getDescription
in class Tester
public int evalState(java.lang.Object state, int depth)
state
.
However, at the top level of recursion (when depth
equals
getDepth()), it returns the number of the best action to take.
state
- depth
- The depth of lookahead
public void reset()
Tester
reset
in class Tester
public int generate()
Tester
generate
in class Tester
public static void main(java.lang.String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |