Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Code coverage tools in Java [closed]

Are there any such code coverage tools in Java that give the different paths in the program. Basically the idea is to ensure that all loops and nested loops are covered during execution. That is to be able to ascertain if all the loops in a code base have been executed at least through one iteration.

like image 921
emkrish Avatar asked Oct 05 '09 05:10

emkrish


People also ask

Which of this is Java code coverage tool?

JaCoCo. JaCoCo is an open-source toolkit for measuring and reporting Java code coverage. JaCoCo is distributed under the terms of the Eclipse Public License. It was developed as a replacement for EMMA, under the umbrella of the EclEmma plug-in for Eclipse.

Which is a code coverage tool?

Cobertura is a code coverage tool. This is actually a code coverage utility tool developed specifically for Java. Cobertura is a free Java tool that calculates the percentage of code accessed by tests. It can be used to identify which parts of your Java program are lacking test coverage.

How does code coverage work in Java?

In simple terms, code coverage analyses each line in the code and confirms if it will be executed by a test case. There are several tools that do this and in this post, we will explore code coverage tools for Java. Cobertura is also available as Maven, Eclipse, Jenkins and IntelliJ Plugin.

What is true about EMMA code coverage tool?

EMMA is an open-source toolkit for measuring and reporting Java code coverage. EMMA distinguishes itself from other tools by going after a unique feature combination: support for large-scale enterprise software development while keeping individual developer's work fast and iterative at the same time.


2 Answers

Cobertura, EMMA and even Clover only do branch/decision coverage (in addition to line/statement coverage, of course). Clover also provides method coverage (which simply measures if a method was entered at all during execution).

For path coverage (plus line/statement coverage), try JMockit Coverage.

A sample report can be found here.

Actually, as of now this is only an initial version of the new path coverage support, which I still need to improve.

like image 102
Rogério Avatar answered Sep 22 '22 05:09

Rogério


Cobertura is another popularly used tool.

like image 20
aberrant80 Avatar answered Sep 20 '22 05:09

aberrant80