nz.ac.waikato.modeljunit.coverage
Interface CoverageMetric

All Superinterfaces:
ModelListener
All Known Implementing Classes:
AbstractCoverage, ActionCoverage, CoverageHistory, StateCoverage, TransitionCoverage, TransitionPairCoverage

public interface CoverageMetric
extends ModelListener

An interface to a test coverage metric.


Method Summary
 void clear()
          Reset all coverage data.
 int getCoverage()
          The number of 'items' covered so far.
 java.lang.String getDescription()
          A medium-length description of this coverage metric.
 java.util.Map<java.lang.Object,java.lang.Integer> getDetails()
          Details of which items have been covered and how many times.
 int getMaximum()
          The maximum coverage possible.
 float getPercentage()
          The current coverage percentage.
 void setGraph(InspectableGraph model, java.util.Map<java.lang.Object,Vertex> state2vertex)
          This is called when the graph seems to be complete.
 
Methods inherited from interface nz.ac.waikato.modeljunit.ModelListener
doneGuard, doneReset, doneTransition, failure, getModel, getName, setModel, startAction
 

Method Detail

getDescription

java.lang.String getDescription()
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.".


clear

void clear()
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.


getCoverage

int getCoverage()
The number of 'items' covered so far. The definition of 'item' depends upon the kind of coverage that is being counted. For example, it could be states, or actions, or transitions, or transition-pairs, or steps, or test sequences etc.


getMaximum

int getMaximum()
The maximum coverage possible. This is useful for calculating the percentage of coverage. Note that a few coverage metrics (like the number of tests, or the total length of the test sequences) have no maximum, so in this case, getMaximum() returns -1. Similarly, getMaximum() may return -1 until the the graph has been fully explored.


getPercentage

float getPercentage()
The current coverage percentage. This is equivalent to (100.0 * getCoverage()) / getMaximum(). So the result will be a large negative number before setModel is called, or for coverage metrics that have no maximum coverage.


getDetails

java.util.Map<java.lang.Object,java.lang.Integer> getDetails()
Details of which items have been covered and how many times. Coverage metrics that cannot provide this level of detail will return null.

The type of objects in the domain of the result map will depend upon the kind of coverage (Action, Transition, TransitionPair etc.). However, all of them should provide a useful toString() method, so that you can print coverage results. A typical use of this method is to iterate through the result map and print all the objects that map to zero, because they have not been covered.

Returns:
Map of how many times each object has been covered, or null.

setGraph

void setGraph(InspectableGraph model,
              java.util.Map<java.lang.Object,Vertex> state2vertex)
This is called when the graph seems to be complete.

Parameters:
model -
state2vertex -


Copyright © 2009 ModelJUnit Project. All Rights Reserved.