Code Coverage Tools
Overview
Let’s look at some code coverage tools and the official URLs used for test coverage analysis of the Java source code.
- Cobertura
- Emma
- JaCoCo
Cobertura
Cobertura is a free Java-based code coverage reporting tool that calculates the test coverage of the source code by the tests. The tool is based on jcoverage.
Official URL: https://cobertura.github.io/cobertura/
We can use the tool in Maven project by adding the Maven dependency to the pom.xml
<dependency>
<groupId>net.sourceforge.cobertura</groupId>
<artifactId>cobertura</artifactId>
<version>2.1.1</version>
<scope>test</scope>
</dependency>
EMMA
EclEmma is a free Java code coverage tool for Eclipse IDE. We can use the tool directly from the Eclipse tool.
Download Eclipse IDE. ( https://www.testingdocs.com/downloading-and-extracting-eclipse-ide/)
We can download and install the Emma tool using the Eclipse Market place.
More information about Eclipse Marketplace:
https://www.testingdocs.com/eclipse-marketplace/
JaCoCo
JaCoCo is a code coverage library for Java, which has been created by the EclEmma team.
https://www.jacoco.org/jacoco/trunk/index.html
Code Coverage with Eclipse
https://www.testingdocs.com/questions/how-to-perform-code-coverage-with-eclipse/