|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnz.ac.waikato.modeljunit.AbstractListener
nz.ac.waikato.modeljunit.coverage.CoverageHistory
public class CoverageHistory
A wrapper class that adds history recording to any CoverageMetric. This is useful for drawing graphs of how the coverage changes over time etc. For example, new CoverageHistory(new ActionCoverage(), 10) behaves exactly the same as the ActionCoverage metric, but also records a snapshot of its coverage level each 10 calls to doneTransition(...).
Note that you must add this CoverageHistory wrapper as the listener to the model, rather than adding the underlying metric. If you add both, the metrics will be recorded twice as fast, which is probably not what you want!
Field Summary |
---|
Fields inherited from class nz.ac.waikato.modeljunit.AbstractListener |
---|
model_ |
Constructor Summary | |
---|---|
CoverageHistory(CoverageMetric metric,
int interval)
Create a history version of the coverage metric. |
Method Summary | |
---|---|
void |
clear()
This resets the history, as well as calling getMetric().reset(); |
void |
doneGuard(java.lang.Object state,
int action,
boolean enabled,
int value)
The Model calls this after each guard evaluation. |
void |
doneReset(java.lang.String reason,
boolean testing)
The Model calls this after each reset(boolean) action. |
void |
doneTransition(int action,
Transition tr)
Delegates to getMetric().doneTransition(...), and records the resulting coverage. |
void |
failure(TestFailureException ex)
The Model calls this when an action has found an error. |
int |
getCoverage()
Returns getMetric().getCoverage(). |
java.lang.String |
getDescription()
Delegates to getMetric().getDescription(). |
java.util.Map<java.lang.Object,java.lang.Integer> |
getDetails()
Returns getMetric().getDetails(). |
java.util.List<java.lang.Integer> |
getHistory()
Returns the list of coverage snapshots. |
int |
getMaximum()
Returns getMetric().getMaximum(). |
CoverageMetric |
getMetric()
Returns the underlying coverage metric. |
java.lang.String |
getName()
Delegates to getMetric().getName(). |
float |
getPercentage()
Returns getMetric().getPercentage(). |
void |
setGraph(InspectableGraph graph,
java.util.Map<java.lang.Object,Vertex> state2vertex)
Delegates to getMetric().setModel(...). |
void |
setModel(Model model)
This tells the underlying metric about the model, even though the model will not be sending events directly to that metric (the events come through this wrapper). |
void |
startAction(java.lang.Object state,
int action,
java.lang.String name)
This is called just before an action is about to be executed. |
java.lang.String |
toCSV()
Converts the history coverage values to a comma-separated string. |
java.lang.String |
toString()
Returns getMetric().toString(). |
Methods inherited from class nz.ac.waikato.modeljunit.AbstractListener |
---|
getModel |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface nz.ac.waikato.modeljunit.ModelListener |
---|
getModel |
Constructor Detail |
---|
public CoverageHistory(CoverageMetric metric, int interval)
metric
- The coverage metric to add history to.interval
- How often to take snapshots.Method Detail |
---|
public CoverageMetric getMetric()
public java.lang.String getName()
getName
in interface ModelListener
public java.lang.String getDescription()
getDescription
in interface CoverageMetric
public void setModel(Model model)
setModel
in interface ModelListener
setModel
in class AbstractListener
public void clear()
clear
in interface CoverageMetric
public void setGraph(InspectableGraph graph, java.util.Map<java.lang.Object,Vertex> state2vertex)
setGraph
in interface CoverageMetric
public int getCoverage()
getCoverage
in interface CoverageMetric
public int getMaximum()
getMaximum
in interface CoverageMetric
public float getPercentage()
getPercentage
in interface CoverageMetric
public java.util.List<java.lang.Integer> getHistory()
public java.util.Map<java.lang.Object,java.lang.Integer> getDetails()
getDetails
in interface CoverageMetric
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toCSV()
public void doneGuard(java.lang.Object state, int action, boolean enabled, int value)
ModelListener
enabled
boolean says whether the guard of action is
enabled or not, while value
gives the actual value returned
by the guard method (0 for false, 1 for true, or other positive
integer values for Markov chain guards).
doneGuard
in interface ModelListener
doneGuard
in class AbstractListener
public void doneReset(java.lang.String reason, boolean testing)
ModelListener
doneReset
in interface ModelListener
doneReset
in class AbstractListener
reason
- An adjective that describe why the reset was done.testing
- The parameter that was passed to the FsmModel reset call.public void startAction(java.lang.Object state, int action, java.lang.String name)
ModelListener
startAction
in interface ModelListener
startAction
in class AbstractListener
state
- The current state of the model.action
- The number of the action.name
- The name of the action.public void doneTransition(int action, Transition tr)
doneTransition
in interface ModelListener
doneTransition
in class AbstractListener
action
- The number of the action just taken.tr
- The transition just taken.public void failure(TestFailureException ex)
ModelListener
failure
in interface ModelListener
failure
in class AbstractListener
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |