How to Generate Emma Code Coverage Report for Maven Project

By ongraph
October 17, 2014 | 2361 Views

Latest Industry insights to keep you updated on the latest happenings.

Features of EMMA:

  • Supported coverage types: class, method, line, basic block. EMMA can detect when a single source code line is covered only partially.
  • Coverage stats are aggregated at method, class, package, and “all classes” levels.
  • Output report types: plain text, HTML, XML. All report types support drill-down, to a user-controlled detail depth. The HTML report supports source code linking.
  • Output reports can highlight items with coverage levels below user-provided thresholds.
  • EMMA can instrument individual .class files or entire .jars (in place, if desired). Efficient coverage subset filtering is possible, too.
  • Makefile and ANT build integration are supported on equal footing.
  • EMMA is quite fast: the runtime overhead of added instrumentation is small (5-20%) and the bytecode instrumentation itself is very fast (mostly limited by file I/O speed). Memory overhead is a few hundred bytes per Java class.
  • EMMA is 100% pure Java, has no external library dependencies, and works in any Java JVM.

 

Step1:- Generate Emma Code Coverage Report:

To generate only emma code coverage report we don't need to do anything, just type the Maven command “mvn emma:emma” to run the maven-emma-plugin.

 

 

Maven will compile the code, run unit test and Emma plugin will generate the code coverage report at ${project}/target/site/index.html.
Here is the sample of Emma code coverage report:

Step2:- Integrate into the Maven Build:

We can also include the “emma-maven-plugin” in the build section. To integrate Emma into maven build we need add entry in POM.xml file.
EMMA plugin entry would be like:

 

Step3:- To compile maven-emma-plugin type the following Maven command “mvn clean install -Pemma”. 

 

Step 4:-Maven will compile the code, run unit test and Emma plugin will generate the code coverage report at ${project}/target/generated-classes/emma

 

Here is the sample of Emma detail code coverage report:

 

Enjoy..!!

Monthly industry insights to keep you updated on latest happenings

Follow us on Twitter
Follow us on Facebook
Follow us on Linkedin