EclEmma 3.1.9 Java Code Coverage for Eclipse Drag to your running Eclipse workspace to install EclEmma Java Code Coverage
Eclipse Community Award 2008
Inspected with sonarqube
jobs at mtrail
The Java Specialists' Newsletter

Frequently Asked Questions




How can I remove the coverage coloring from the Java editors again?

If you remove the coverage session, also the coverage coloring will disappear. For this, hit Remove Session or Remove All Sessions in the Coverage view's toolbar.

How can I run {whateverapplication} with EclEmma?

EclEmma is designed for Java programs launched within Eclipse. Java applications that run in a different environment may be directly analyzed with JaCoCo using for example the Ant or Maven integrations. There are different supported launch types, other plug-ins may define additional launch types which are not supported by EclEmma. Check user documentation for currently supported launch types.

Does EclEmma support automated Ant or Maven builds?

EclEmma is a Eclipse integration of the JaCoCo code coverage tool. JaCoCo comes with a set of Ant tasks and Maven goals for automated builds.

How do I change the source code highlighting?

The source code highlighting can be changed in the Eclipse Preference dialog at General → Appearance → Editors → Text Editors → Annotations. You can modify the highlighting style and color or use the vertical rulers instead.

Do I need source code to use EclEmma?

No, you can also get coverage information for e.g. third-party JARs. Just make them part of your class path settings in Eclipse and select them on the Coverage tab in the coverage launch dialog. If the library was compiled with debug information, line coverage will be shown in the Coverage view. In case the source is properly attached to the library syntax highlighting will happen in the editors the same way as with you source code.

Why is this line yellow?

EclEmma annotates all lines which are partly covered in yellow. Partly covered means that not all instructions and branches associated with this line have been executed during the coverage session. In some cases it is not obvious why the Java compiler creates extra byte code for a particular line of source code. Such situations might be filtered by future versions of JaCoCo and EclEmma.

How can I exclude test classes from analysis?

The analysis scope for coverage sessions can be defined in the Coverage launch dialog on source folder (or library) granularity. As test code is typically kept in separate source folders or projects this allows to exclude your test classes from coverage analysis.


Why do I get the error message "No coverage data has been collected during this coverage session"?

This happens when the Java process did not terminate properly, e.g. has been manually killed with the Terminate button. Make sure your Java program terminates on its own. Alternatively you can dump coverage data for the running process before you terminate it. For this select the button Dump Execution Data from the Coverage view's toolbar.

Source code lines with exceptions show no coverage. Why?

The underlying JaCoCo code coverage library determines code execution with so called probes. Probes are inserted into the control flow at certain positions. Code is considered as executed when a subsequent probe has been executed. In case of exceptions such a sequence of instructions is aborted somewhere in the middle and the corresponding line of source code is not marked as covered.

My application does not run with EclEmma!

Does your application properly execute within Eclipse in normal run mode? Please verify! If not, your app will most likely not execute in coverage mode either. In this case first create a proper launch configuration in Eclipse; then execute in coverage mode.

My Eclipse workbench window has no toolbar button for coverage launches!

Even if EclEmma is installed properly, it will show its action sets only in some predefined perspectives related to Java tasks. If you want to use the coverage toolbar in other perspectives like Resource select Customize Perspective... from the toolbar's context menu and check the Java Code Coverage option on the Command Groups Availability tab.

Why are JUnit4 test cases with expected exceptions shown as not covered?

JUnit4 test cases with expected exceptions are shown as not covered even though they were executed. The reason for this is that underlying JaCoCo code coverage library only considers code as executed when certain probes are executed. For successful test cases marked with @Test{expected=...} this is not the case. See also "Source code lines with exceptions show no coverage. Why?".

The Coverage view stays empty and there is no source highlighting. Why?

In Eclipse preferences there is an option Launch in debug mode when workspace contains breakpoints under Run/DebugLaunching. If this option is enabled and there are breakpoints in your workspace coverage mode will not work, because it is automatically replaced with debug mode. Set this option to Never if you want to run code coverage analysis.