nz.ac.waikato.modeljunit.coverage
Class StateCoverage

java.lang.Object
  extended by nz.ac.waikato.modeljunit.AbstractListener
      extended by nz.ac.waikato.modeljunit.coverage.AbstractCoverage
          extended by nz.ac.waikato.modeljunit.coverage.StateCoverage
All Implemented Interfaces:
CoverageMetric, ModelListener

public class StateCoverage
extends AbstractCoverage

Counts the number of times each state has been entered. Each reset will increment the count of the initial state. Each transition will increment the count of its target state.

The getCoverage method will return the total number of states visited since the last clear. The getMaximum method will return the total number of states in the graph, if this is known.


Field Summary
protected  boolean todoReset_
           
 
Fields inherited from class nz.ac.waikato.modeljunit.coverage.AbstractCoverage
coverage_, currCoverage_, maxCoverage_
 
Fields inherited from class nz.ac.waikato.modeljunit.AbstractListener
model_
 
Constructor Summary
StateCoverage()
           
 
Method Summary
 void clear()
          Reset all coverage data.
 void doneReset(java.lang.String reason, boolean testing)
          Increments the count of the initial state.
 void doneTransition(int action, Transition tr)
          Increments the count of the target state of the transition.
 java.lang.String getDescription()
          A medium-length description of this coverage metric.
 java.lang.String getName()
          Get the short name that this listener is known by.
 void setGraph(InspectableGraph model, java.util.Map<java.lang.Object,Vertex> state2vertex)
          A default implementation that does nothing.
 
Methods inherited from class nz.ac.waikato.modeljunit.coverage.AbstractCoverage
addItem, getCoverage, getDetails, getMaximum, getPercentage, incrementItem, toString, transition
 
Methods inherited from class nz.ac.waikato.modeljunit.AbstractListener
doneGuard, failure, getModel, setModel, startAction
 
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
doneGuard, failure, getModel, setModel, startAction
 

Field Detail

todoReset_

protected boolean todoReset_
Constructor Detail

StateCoverage

public StateCoverage()
Method Detail

getName

public java.lang.String getName()
Description copied from interface: ModelListener
Get the short name that this listener is known by. This name is used to add a listener to a model or a Tester object and to lookup a listener. The name should be a short descriptive noun phrase, all in lowercase, should usually be less than 30 characters, and may contain spaces.


getDescription

public java.lang.String getDescription()
Description copied from interface: CoverageMetric
A medium-length description of this coverage metric. This should be a sentence or paragraph suitable for displaying as pop-up documentation, to explain the metric. For example, a state coverage metric might return "The number of different FSM states visited.".


setGraph

public void setGraph(InspectableGraph model,
                     java.util.Map<java.lang.Object,Vertex> state2vertex)
Description copied from class: AbstractCoverage
A default implementation that does nothing.

Specified by:
setGraph in interface CoverageMetric
Overrides:
setGraph in class AbstractCoverage

clear

public void clear()
Description copied from class: AbstractCoverage
Reset all coverage data. After calling this method, getCoverage() will return 0. Resetting the coverage does not imply that the model has changed, so the result of getMaximum() should be unchanged.

The default implementation iterates through the coverage_ map and resets all counts to zero, and also resets currCoverage_ to zero, to maintain the invariant.

Specified by:
clear in interface CoverageMetric
Overrides:
clear in class AbstractCoverage

doneReset

public void doneReset(java.lang.String reason,
                      boolean testing)
Increments the count of the initial state. However, this is done just once for each sequence of resets.

Specified by:
doneReset in interface ModelListener
Overrides:
doneReset in class AbstractCoverage
Parameters:
reason - An adjective that describe why the reset was done.
testing - The parameter that was passed to the FsmModel reset call.

doneTransition

public void doneTransition(int action,
                           Transition tr)
Increments the count of the target state of the transition.

Specified by:
doneTransition in interface ModelListener
Overrides:
doneTransition in class AbstractListener
Parameters:
action - The number of the action just taken.
tr - The transition just taken.


Copyright © 2009 ModelJUnit Project. All Rights Reserved.