Code Coverage Tools
Code Coverage Tools
A Code Coverage Tool is software that measures the degree to which a program’s source code has been tested. This helps identify which parts of the code have been executed or covered by test cases and which parts have not.
Let’s examine some code coverage tools and the official URLs used to analyze test coverage in Java source code.
- Cobertura
- Emma
- JaCoCo
Code Coverage Video Tutorial
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:
JaCoCo
JaCoCo is a code coverage library for Java, created by the EclEmma team.