Test Coverage

Test coverage is a metric that describes to which extent your code is covered by your tests. Translated to statechart modelling, a test coverage describes which parts of your state machine were activated during test execution. This information allows to identify missing tests and thereby to increase test quality.

Whenever a test set is executed, a test coverage is computed on the fly. The test coverage metrics can be examined in the Coverage View. The coverage value is given in percent for each model element and is defined as follows:

  • Transition coverage is 100% if the transition is executed at least once, and 0% otherwise.
  • A state is covered if it is entered and all of its outgoing transitions are covered.
  • Region coverage is the weighted average coverage of all contained states.
  • Statechart coverage is the weighted average coverage of its top level regions.

In the following example you can see that state On has a coverage of 50%. Although it is entered by the tests, its outgoing transition On -> Off is not covered.

SCTUnit Coverage View

The coverage view contains the following toolbar buttons:

  • Coverage View hide covered: Shows / hides fully covered elements in the tree
  • Coverage View hide covered: Clears the view and removes the coverage highlighting in the model

The coverage highlighting feature transports the coverage values directly onto the statechart model by coloring all elements in the colors:

  • green (fully covered),
  • yellow (not fully covered), and
  • red (not covered at all).

You can enable the highlighting by selecting an arbitrary element in the coverage view.

Test Coverage Highlighting