A few words of thanks would be greatly appreciated.

EclEmma Plugin

The code coverage refers to a technique for programming technology by which you measure the quality and comprehensiveness of your test suite with a simple metric such as the percentage of classes, methods, lines, etc. that have been successfully been executed during the test suite.

Several tools allow code coverage:
  • Clover
  • Corbertura
  • Emma.

In our case, we will check out the EclEmma plugin.

Introducing the EclEmma plugin

EclEmma is a free Java code coverage tool for the Eclipse IDE, it is a plugin that is combined with JUnit.
When unit tests are launched, the tool will analyze upon the code and will perform a (color) marking upon it. For example, the red color is used to display part of thecode that unit testing does not cover. It is therefore possible to verify a glance the pieces of code that are supported or not.

Source Code Analysis

After running the application or testing unit, the information about the code coverage is automatically available in Eclipse workbench:
Overview: the code coverage lists summaries for projects in java.

The analysis provides figures by line of code, by method, type, etc. as shown in the screenshots below:

Methods coverage range:

Line coverage range:

Source highlighting: The results of the code coverage are also directly visible in the java source code through a color-coded marking. The colors used by default are:
  • The green color: For fully covered lines.
  • The yellow color code: to display the partially covered items (unit tests)
  • The red color: is used to display part of the code that unit testing does not cover.
  • These colors are set in eclipse:
  • Menu windows-> preferences-> General-> Editors-> Text Editors -> Annotations
  • As for the annotations, you should get: "full coverage range," "partial coverage range" and "without coverage range" with the choice of corresponding colors.

Import and Export Features

EclEmma is primarily intended for testing and analysis within the Eclipse workbench, but it also provides a mechanism for import/export.
  • Import code coverage report: Possibility to import a session in the *.ec format.
  • Export code coverage report: The data may be exported in XML or HTML format.

Exporting code coverage report:


A few words of thanks would be greatly appreciated.

Ask a question
CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jean-François Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.
This document, titled « EclEmma Plugin », is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (ccm.net).