Part 3 – Find Code Coverage in Eclipse : EclEmma Configuration

ecl

What have we learned so far

1. Sonar Server Configuration
PART 1 : SETTING UP SONAR SERVER LOCALLY


2. Integrate JaCoCo plugin with Sonar and Maven for Code Coverage.
PART 2 – INTEGRATE JACOCO PLUGIN WITH SONAR AND MAVEN FOR CODE COVERAGE

EclEmma Configuration in Eclipse
How to find out the code coverage in eclipse?
Many time we want to find out the code coverage of our files before pushing the code into git repository. Till now we saw that Sonar can tell use the overall code coverage percentage and file wise code coverage. But what if I want to calculate it before moving the code to git repo?
We can do this by using EclEmma plugin in Eclipse. It brings code coverage analysis directly into the Eclipse workbench.

Please follow below steps to configure EclEmma in Eclipse.

Step 1: From your Eclipse menu select HelpEclipse Marketplace.

Step 2. Search for “EclEmma”.

Step 3. Hit Install for the entry “EclEmma Java Code Coverage”.

Step 4. Follow the steps in the installation wizard.

Once you complete the installation, you will be able to see a new menu Coverage As for each project or Java file.

el1

To calculate the code coverage, click on Coverage As and then JUnit Test.
This will give us the code coverage in Eclipse under the Coverage dialog box as shown below.

el2

We can also check the code coverage percentage of each file as below.

el3

Source lines containing executable code get the following color code:

el5
  • green for fully covered lines,
  • yellow for partly covered lines (some instructions or branches missed) and
  • red for lines that have not been executed at all.