EclEmma 1.3.2 Java Code Coverage for Eclipse SourceForge.net Logo
Eclipse Community Award 2008

Using the Coverage View

The Coverage view automatically appears when a new coverage session is added or can manually opened from the Window → Show View menu in the Java category. It shows coverage summaries for the active session.

Coverage View

The Coverage view shows all instrumented Java elements within the common Java hierarchy. For each element the total number of items and the number of items covered within the active session is shown, always including the child elements of the respective Java element. You can select between different metrics, see last section for details.

The elements may be re-ordered by clicking the respective column header. Double-clicking an element opens its declaration in an editor with highlighted source code.

Toolbar and Drop-Down Menu

Coverage View Tools

The coverage view's toolbar offers the following actions:

  • Coverage Last Launched: Re-run the currently selected coverage session.
  • Remove Active Session: Remove the currently selected coverage session.
  • Remove All Sessions: Remove all coverage sessions.
  • Merge Sessions: Merges multiple sessions into a single one.
  • Select Session: Select session from the drop down-menu and make it the active session.
  • Collapse All: Collapse all expanded tree nodes.
  • Link with Current Selection: If this toggle is checked the coverage view automatically reveals the Java element currently selected in other views or editors.

Some of the actions are deactivated if there is no session or only a single session. More settings are available form the coverage view's drop-down menu:

Coverage View Drop-Down Menu

  • Show Elements: Select Java elements shown as root entries in the coverage tree: Projects, package fragment roots (source folders or libraries), package fragments or types.
  • Counter Mode: Different counter modes can be selected from the view's drop-down menu: bytecode instructions, basic blocks, lines, methods and types. See next sections for details.
  • Hide Unused Types: Filter all Java types from the coverage view that has not been loaded during the coverage session.

Counters

When analyzing the coverage data collected during a coverage session different counters are evaluated for each Java element. The coverage view allows to select from its drop-down menu which counter should be displayed:

  • Basic Blocks: This is EMMA's fundamental unit of coverage. A basic block is a sequence of bytecode instructions without any jumps or jump targets. A basic block is considered as covered when its last instruction has been executed.
  • Lines: The number of covered Java source code lines. A source line is considered as covered if it contains at least one covered basic block. This counter is only available if the line numbers are included in the compiled class files (debug mode).
  • Bytecode Instructions: The number of bytecode instructions within the basic blocks. If no line information is available this is a good approximation for line coverage.
  • Methods: A method is considered as covered if at least one basic block of the method has been executed.
  • Types: A Java type is considered as covered if it has been loaded and initialized.

Filtering

If you're working on a particular unit you can filter out all classes which have not been loaded during the test run. This filtering can be enabled with the Hide Unused Types menu entry in the Coverage view's drop-down menu.

Tip: Combine the Hide Unused Types option with types as root entries. This will give you a plain list of all classes loaded for your test case.