Cobertura
   HOME

TheInfoList



OR:

Java code coverage tools are of two types: first, tools that add statements to the
Java Java is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea (a part of Pacific Ocean) to the north. With a population of 156.9 million people (including Madura) in mid 2024, proje ...
source code In computing, source code, or simply code or source, is a plain text computer program written in a programming language. A programmer writes the human readable source code to control the behavior of a computer. Since a computer, at base, only ...
and require its recompilation. Second, tools that instrument the
bytecode Bytecode (also called portable code or p-code) is a form of instruction set designed for efficient execution by a software interpreter. Unlike human-readable source code, bytecodes are compact numeric codes, constants, and references (normal ...
, either before or during execution. The goal is to find out which parts of the code are tested by registering the lines of code executed when running a test.


JaCoCo

JaCoCo is an
open-source Open source is source code that is made freely available for possible modification and redistribution. Products include permission to use and view the source code, design documents, or content of the product. The open source model is a decentrali ...
toolkit for measuring and reporting
Java Java is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea (a part of Pacific Ocean) to the north. With a population of 156.9 million people (including Madura) in mid 2024, proje ...
code coverage In software engineering, code coverage, also called test coverage, is a percentage measure of the degree to which the source code of a program is executed when a particular test suite is run. A program with high code coverage has more of its ...
. JaCoCo is distributed under the terms of the
Eclipse Public License The Eclipse Public License (EPL) is a free and open source software license most notably used for the Eclipse IDE and other projects by the Eclipse Foundation. It replaces the Common Public License (CPL) and removes certain terms relating t ...
. It was developed as a replacement for EMMA,JaCoCo Mission
/ref> under the umbrella of the EclEmma plug-in for Eclipse.


Features

JaCoCo offers instructions, line and branch coverage. In contrast to Atlassian Clover and OpenClover, which require instrumenting the source code, JaCoCo can instrument Java bytecode using two different approaches: * like JCov on the fly while running the code with a Java agent * like Cobertura and JCov prior to execution (offline) And can be configured to store the collected data in a file, or send it via TCP. Files from multiple runs or code parts can be merged easily. Unlike Cobertura and EMMA it fully supports Java 7, Java 8, Java 9, Java 10, Java 11, Java 12, Java 13, Java 14, Java 15, Java 16, Java 17, Java 18, Java 19 and Java 20.


Tools using or including JaCoCo

* SonarQube JaCoCo plugin — one of the defaults for coverage analyses within the code quality management platform
SonarQube SonarQube (formerly Sonar) is an open-source platform developed by SonarSource for continuous inspection of code quality to perform automatic reviews with static analysis of code to detect bugs and code smells on 29 programming languages. Sona ...
* EclEmma
Eclipse (software) Eclipse is an integrated development environment (IDE) used in computer programming. It contains a base workspace and an extensible plug-in system for customizing the environment. It had been the most popular IDE for Java development until 20 ...
Code Coverage Plugin, was formerly EMMA based *
Jenkins Jenkins may refer to: People * Jenkins (name), history of the surname * List of people with surname Jenkins * The Jenkins, country music group Places United States * Jenkins, Illinois *Jenkins, Kentucky * Jenkins, Minnesota * Jenkins, Missour ...
JaCoCo Plugin *
Netbeans NetBeans is an integrated development environment (IDE) for Java (programming language), Java. NetBeans allows applications to be developed from a set of modular software components called ''modules''. NetBeans runs on Microsoft Windows, Windows, ...
JaCoCo support *
IntelliJ IDEA IntelliJ IDEA () is an integrated development environment (IDE) written in Java for developing computer software written in Java, Kotlin, Groovy, and other JVM-based languages. It is developed by JetBrains (formerly known as IntelliJ) and is a ...
since v11 *
Gradle Gradle is a build automation tool for multi-language software development. It manages tasks like compilation, packaging, testing, deployment, and publishing. Supported languages include Java (as well as JDK-based languages Kotlin, Groovy, Sc ...
JaCoCo Plugin *
Maven MAVEN is a NASA spacecraft orbiting Mars to study the loss of that planet's atmospheric gases to space, providing insight into the history of the planet's climate and water. The name is an acronym for "Mars Atmosphere and Volatile Evolution" w ...
JaCoCo Plugin *
Visual Studio Team Services Visual Studio is an integrated development environment (IDE) developed by Microsoft. It is used to develop computer programs including web site, websites, web apps, web services and mobile apps. Visual Studio uses Microsoft software development ...
*
TeamCity TeamCity is a build management and continuous integration server from JetBrains. It was first released on October 2, 2006 and is commercial software and licensed under a proprietary license: a freemium license for up to 100 build configuration ...
* STAMP (https://www.stamp-project.eu/)


JCov

JCov is the tool which has been developed and used with Sun JDK (and later Oracle JDK) from the very beginning of Java: from the version 1.1. JCov is capable of measuring and reporting
Java Java is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea (a part of Pacific Ocean) to the north. With a population of 156.9 million people (including Madura) in mid 2024, proje ...
code coverage In software engineering, code coverage, also called test coverage, is a percentage measure of the degree to which the source code of a program is executed when a particular test suite is run. A program with high code coverage has more of its ...
. JCov is distributed under the terms of the
GNU General Public License The GNU General Public Licenses (GNU GPL or simply GPL) are a series of widely used free software licenses, or ''copyleft'' licenses, that guarantee end users the freedom to run, study, share, or modify the software. The GPL was the first ...
(version 2, with the Classpath Exception). JCov has become open-source as a part of OpenJDK code tools project in 2014.


Features

JCov is capable of reporting the following types of code coverage: * Block coverage * Line coverage * Branch coverage * Method coverage JCov implements two different ways to save the collected data: * Into a file on the filesystem * Onto a server (a.k.a. "network grabber") JCov works by instrumenting Java bytecode using two different approaches: * Static instrumentation which is done upfront, changing the tested code * Dynamic instrumentation which is done on the fly by means of Java agent JCov has a few more distinctive features which include, but are not limited to: * Field coverage * Abstract API coverage * Direct/indirect coverage * Per-test coverage information (a.k.a. "test scales") * Public API and SPI which makes it possible to implement custom filtering and/or mining the coverage data


Tools using JCov

* Oracle JDK (SE and ME) * JCK (the Java Compatibility Kit) * Various Java SE and Java ME TCKs * Java FX SDK * Java FX Scene Builder


OpenClover

OpenClover is a free and open-source successor of Atlassian Clover, created as a
fork In cutlery or kitchenware, a fork (from 'pitchfork') is a utensil, now usually made of metal, whose long handle terminates in a head that branches into several narrow and often slightly curved tines with which one can spear foods either to h ...
from the Clover code base published by Atlassian in 2017. It contains all features of the original Clover (the server edition). The OpenClover project is led by developers who maintained Clover in years 2012–2017. OpenClover uses source code instrumentation technique and handles Java,
Groovy ''Groovy'' (or, less commonly, ''groovie'' or ''groovey'') is a slang colloquialism popular during the 1960s and 1970s. It is roughly synonymous with words such as "excellent", "fashionable", or "amazing", depending on context. History The word ...
and
AspectJ AspectJ is an aspect-oriented programming (AOP) extension for the Java programming language, created at PARC. It is available in Eclipse Foundation open-source projects, both stand-alone and integrated into Eclipse. AspectJ has become a widely ...
languages. Some of its features include: fine control over scope of coverage measurement, test optimisation and sophisticated reports. OpenClover integrates with
Ant Ants are Eusociality, eusocial insects of the Family (biology), family Formicidae and, along with the related wasps and bees, belong to the Taxonomy (biology), order Hymenoptera. Ants evolved from Vespoidea, vespoid wasp ancestors in the Cre ...
,
Maven MAVEN is a NASA spacecraft orbiting Mars to study the loss of that planet's atmospheric gases to space, providing insight into the history of the planet's climate and water. The name is an acronym for "Mars Atmosphere and Volatile Evolution" w ...
,
Gradle Gradle is a build automation tool for multi-language software development. It manages tasks like compilation, packaging, testing, deployment, and publishing. Supported languages include Java (as well as JDK-based languages Kotlin, Groovy, Sc ...
, Grails,
Eclipse An eclipse is an astronomical event which occurs when an astronomical object or spacecraft is temporarily obscured, by passing into the shadow of another body or by having another body pass between it and the viewer. This alignment of three ...
,
IntelliJ IDEA IntelliJ IDEA () is an integrated development environment (IDE) written in Java for developing computer software written in Java, Kotlin, Groovy, and other JVM-based languages. It is developed by JetBrains (formerly known as IntelliJ) and is a ...
,
Bamboo Bamboos are a diverse group of mostly evergreen perennial plant, perennial flowering plants making up the subfamily (biology), subfamily Bambusoideae of the grass family Poaceae. Giant bamboos are the largest members of the grass family, in th ...
,
Jenkins Jenkins may refer to: People * Jenkins (name), history of the surname * List of people with surname Jenkins * The Jenkins, country music group Places United States * Jenkins, Illinois *Jenkins, Kentucky * Jenkins, Minnesota * Jenkins, Missour ...
,
Hudson Hudson may refer to: People * Hudson (given name) * Hudson (surname) * Hudson (footballer, born 1986), Hudson Fernando Tobias de Carvalho, Brazilian football right-back * Hudson (footballer, born 1988), Hudson Rodrigues dos Santos, Brazilian f ...
, Griffon,
SonarQube SonarQube (formerly Sonar) is an open-source platform developed by SonarSource for continuous inspection of code quality to perform automatic reviews with static analysis of code to detect bugs and code smells on 29 programming languages. Sona ...
and AspectJ.


IntelliJ IDEA Code Coverage Agent

IntelliJ IDEA Code Coverage Agent is a
code coverage In software engineering, code coverage, also called test coverage, is a percentage measure of the degree to which the source code of a program is executed when a particular test suite is run. A program with high code coverage has more of its ...
tool integrated in IntelliJ IDEA IDE and TeamCity CI server. It supports branch coverage and per-test coverage tracking.


Testwell CTC++ for Java

Testwell CTC++ is a
code coverage In software engineering, code coverage, also called test coverage, is a percentage measure of the degree to which the source code of a program is executed when a particular test suite is run. A program with high code coverage has more of its ...
tool for C, C++,
Java Java is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea (a part of Pacific Ocean) to the north. With a population of 156.9 million people (including Madura) in mid 2024, proje ...
and C#. The development of this tool started in 1989 at Testwell in Finland. Since 2013 support and development has been continued by Verifysoft Technology, a company from
Offenburg Offenburg (; "open borough" - coat of arms showing open gates; Low Alemmanic: ''Offäburg'') is a city in the state of Baden-Württemberg, in south-western Germany. With nearly 60,000 inhabitants (2019), it is the largest city and the administrat ...
,
Germany Germany, officially the Federal Republic of Germany, is a country in Central Europe. It lies between the Baltic Sea and the North Sea to the north and the Alps to the south. Its sixteen States of Germany, constituent states have a total popu ...
. Testwell CTC++ analyses for all code coverage levels up to Modified condition/decision coverage and Multicondition Coverage.Testwell CTC++ supports all coverage levels
/ref> The tool works with all
compilers In computing, a compiler is a computer program that translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primarily used for programs tha ...
.Testwell CTC++ supports all compilers
/ref>


Notable historic tools


Clover

Clover is a Java
code coverage In software engineering, code coverage, also called test coverage, is a percentage measure of the degree to which the source code of a program is executed when a particular test suite is run. A program with high code coverage has more of its ...
analysis utility bought and further developed by
Atlassian Atlassian Corporation () is an Australia, Australian-United States, American proprietary software company that specializes in collaboration tools designed primarily for software development and project management. Domicile (law), Domiciled in ...
. In April 2017 Atlassian announced end-of-life of Clover and at the same time open-sourced it under Apache 2.0 license. Clover uses a source code instrumentation technique (as opposed to Cobertura and JaCoCo, which use byte code instrumentation), which has its advantages (such as an ability to collect code metrics) and disadvantages (re-compilation of sources is necessary). Some of its features include historical reporting, huge control over the coverage gathering process, command line toolset and API for legacy integration and more. Clover also allows testing time to be reduced by only running the tests that cover the application code that was modified since the previous build. This is called Test Optimization and can lead to huge drops in the amount of time spent waiting for automated tests to complete. Clover comes with a number of integrations both developed by Atlassian (Ant, Maven, Grails, Eclipse, IDEA, Bamboo) and by open source community (Gradle, Griffon, Jenkins, Hudson, Sonar). In April 2017, Atlassian announced that they would no longer release new versions of Clover after version 4.1.2, and its code was made available as
open-source software Open-source software (OSS) is Software, computer software that is released under a Open-source license, license in which the copyright holder grants users the rights to use, study, change, and Software distribution, distribute the software an ...
hosted on
Bitbucket Bitbucket is a Git-based source code repository hosting service owned by Atlassian. Bitbucket offers both commercial plans and free accounts with an unlimited number of private repositories. Services Bitbucket Cloud Bitbucket Cloud (pre ...
.


Cobertura

Cobertura is an
open-source Open source is source code that is made freely available for possible modification and redistribution. Products include permission to use and view the source code, design documents, or content of the product. The open source model is a decentrali ...
tool for measuring code coverage. It does so by instrumenting the byte code. It was the predecessor to JaCoCo.


EMMA

EMMA is an
open-source Open source is source code that is made freely available for possible modification and redistribution. Products include permission to use and view the source code, design documents, or content of the product. The open source model is a decentrali ...
toolkit for measuring and reporting
Java Java is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea (a part of Pacific Ocean) to the north. With a population of 156.9 million people (including Madura) in mid 2024, proje ...
code coverage In software engineering, code coverage, also called test coverage, is a percentage measure of the degree to which the source code of a program is executed when a particular test suite is run. A program with high code coverage has more of its ...
. EMMA is distributed under the terms of
Common Public License In computing, the Common Public License (CPL) is a free software / open-source software license published by IBM. The Free Software Foundation and Open Source Initiative have approved the license terms of the CPL. Definition The CPL has the stat ...
v1.0. EMMA is not currently under active development; the last stable release took place in mid-2005. As replacement, JaCoCo was developed. EMMA works by wrapping each line of code and each condition with a flag, which is set when that line is executed.Expert Spring MVC and Web Flow; By Seth Ladd, Darren Davison, Steven Devijver, Colin Yates, p. 289
/ref>


Features

* instrument classes for coverage either offline (before they are loaded) or on the fly (using an instrumenting application classloader). * 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. * Coverage data obtained in different instrumentation or test runs can be merged. * it is possible to dump or reset coverage data remotely and without a JVM exit. * does not require access to the source code and degrades gracefully with decreasing amount of debug information available in the input classes. * 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. * The runtime overhead of added instrumentation is small (5–20%) and the bytecode instrumentor 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 2 JVM (even 1.2.x).


Serenity

Serenity is an
open-source Open source is source code that is made freely available for possible modification and redistribution. Products include permission to use and view the source code, design documents, or content of the product. The open source model is a decentrali ...
tool creating better-automated software acceptance tests in less time. It and measures and reports
Java Java is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea (a part of Pacific Ocean) to the north. With a population of 156.9 million people (including Madura) in mid 2024, proje ...
code coverage In software engineering, code coverage, also called test coverage, is a percentage measure of the degree to which the source code of a program is executed when a particular test suite is run. A program with high code coverage has more of its ...
. It also generates easy-to-understand reports that describe what the application does and how it works, including which tests were run an
what requirements were met
It works with Selenium WebDriver, Appium, and BDD tools. Major code metrics such as
cyclometric complexity Cyclomatic complexity is a software metric used to indicate the complexity of a program. It is a quantitative measure of the number of linearly independent paths through a program's source code. It was developed by Thomas J. McCabe, Sr. in 1976. ...
, stability, abstractness, and distance from main are measured. The report data is persisted to an object database and made available via Jenkins/Hudson. The interface visually replicates the Eclipse IDE interface. Serenity dynamically enhances the byte code, making a post-compile step unnecessary. Ant and Maven projects are supported. Configuration is done in xml, an Ant example would be: And a Maven configuration example would be: -Dincluded.packages=your.package.name.here -Dincluded.adapters=coverage,complexity,dependency -javaagent:serenity/serenity.jar -Xms512m -Xmx1024m $ $ For a full example of a configuration please refer to the Jenkins wiki at https://wiki.jenkins-ci.org/display/JENKINS/Serenity+Plugin. Jenkins slaves as well as Maven multi module projects are supported.


References


Citations

*


External links


Comparison of OpenClover, Clover, Cobertura, JaCoCo, JCov, CodeCover and PIT



Pick your code coverage tool in Sonar 2.2
{{Webarchive, url=https://web.archive.org/web/20130223183739/http://www.sonarsource.org/pick-your-code-coverage-tool-in-sonar-2-2/ , date=2013-02-23 , a little outdated, as JaCoCo meanwhile supports branch coverage
Testing Java Applications with Visual Studio Team Services
Software testing tools
Code coverage In software engineering, code coverage, also called test coverage, is a percentage measure of the degree to which the source code of a program is executed when a particular test suite is run. A program with high code coverage has more of its ...