Java code coverage tools

Java code coverage tools are of two types: first, tools that add statements to the Java source code and require its recompilation. Second, tools that instrument the bytecode, 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
Developer(s)Marc Hoffmann, Brock Janiczak, Evgeny Mandrikov, Mirko Friedenhagen
Stable release
0.8.12 / March 31, 2024; 8 months ago (2024-03-31)
TypeCode coverage
LicenseEPL
Websitewww.jacoco.org/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,[1] 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[2]
  • 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.[3] Unlike Cobertura and EMMA it fully supports Java 7, Java 8,[4] 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


JCov

JCov
Developer(s)Leonid Arbouzov, Alexander Petrov, Vladimir Generalov, Serguei Chukhontsev, Oleg Uliankin, Gregory Steuck, Pavel Ozhdikhin, Konstantin Bobrovsky, Robert Field, Alexander Kuzmin, Leonid Mesnik, Sergey Borodin, Andrey Titov, Dmitry Fazunenko, Alexey Fedorchenko, Leonid Kuskov
Stable release
3.0 / September 1, 2014; 10 years ago (2014-09-01)
TypeCode coverage
LicenseGPL v2 (with the Classpath Exception)
Websitewiki.openjdk.java.net/display/CodeTools/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 code coverage. JCov is distributed under the terms of the GNU General Public License (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
Developer(s)Marek Parfianowicz, Grzegorz Lewandowski
Stable release
4.5.2 / January 31, 2024; 10 months ago (2024-01-31)
TypeCode coverage
LicenseApache License 2.0
Websiteopenclover.org

OpenClover is a free and open-source successor of Atlassian Clover, created as a fork 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.[15]

OpenClover uses source code instrumentation technique and handles Java, Groovy and AspectJ languages. Some of its features include: fine control over scope of coverage measurement, test optimisation and sophisticated reports.

OpenClover integrates with Ant, Maven, Gradle, Grails, Eclipse, IntelliJ IDEA, Bamboo, Jenkins, Hudson, Griffon, SonarQube and AspectJ.

IntelliJ IDEA Code Coverage Agent

IntelliJ IDEA Code Coverage Agent
Developer(s)JetBrains
TypeCode coverage
LicenseApache 2.0
Websitegithub.com/JetBrains/intellij-coverage

IntelliJ IDEA Code Coverage Agent is a code coverage 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++
Developer(s)Verifysoft Technology
Stable release
8.0. / June 30, 2016; 8 years ago (2016-06-30)
TypeCode coverage
LicenseProprietary
Websiteverifysoft.com/en_ctcpp.html

Testwell CTC++ is a code coverage tool for C, C++, Java 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, Germany. Testwell CTC++ analyses for all code coverage levels up to Modified condition/decision coverage and Multicondition Coverage.[16] The tool works with all compilers.[17]

Notable historic tools

Clover

Clover
Developer(s)Atlassian
Stable release
4.1.2 / October 11, 2016; 8 years ago (2016-10-11)
TypeCode coverage
LicenseApache 2.0
Websiteatlassian.com

Clover is a Java code coverage analysis utility bought and further developed by Atlassian. 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).[18] 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[19] 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 hosted on Bitbucket.[20][21]

Cobertura

Cobertura
Developer(s)Steven Christou
Stable release
2.1.1 / February 26, 2015; 9 years ago (2015-02-26)
Repositorygithub.com/cobertura/cobertura
TypeCode coverage
LicenseGPL 2.0
Websitecobertura.github.io/cobertura/

Cobertura is an open-source tool for measuring code coverage. It does so by instrumenting the byte code. It was the predecessor to JaCoCo.

EMMA

EMMA
Developer(s)Vlad Roubtsov
Stable release
2.1 / May 13, 2005; 19 years ago (2005-05-13)
Repositorysourceforge.net/projects/emma/
TypeCode coverage
LicenseCommon Public License 1.0
Websiteemma.sourceforge.net

EMMA is an open-source toolkit for measuring and reporting Java code coverage. EMMA is distributed under the terms of Common Public License v1.0.

EMMA is not currently under active development; the last stable release took place in mid-2005. As replacement, JaCoCo was developed.[22] EMMA works by wrapping each line of code and each condition with a flag, which is set when that line is executed.[23]

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
Developer(s)Michael Couck
Stable release
1.0 / December 8, 2013; 11 years ago (2013-12-08)
TypeCode coverage
LicenseApache Software License version 2.0
Websitewiki.jenkins-ci.org/display/JENKINS/Serenity+Plugin

Serenity is an open-source tool creating better-automated software acceptance tests in less time. It and measures and reports Java code coverage. It also generates easy-to-understand reports that describe what the application does and how it works, including which tests were run and what requirements were met. It works with Selenium WebDriver, Appium, and BDD tools.

Major code metrics such as cyclometric complexity, 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:

<!-- Serenity system properties. -->
<sysproperty key="included.packages" value="your.package.name.here" />
<sysproperty key="included.adapters" value="coverage,complexity,dependency" />
<!-- Serenity JVM command line. -->
<jvmarg line="-javaagent:serenity/serenity.jar" />

And a Maven configuration example would be:

<properties>
<included.packages>-Dincluded.packages=your.package.name.here</included.packages>
<included.adapters>-Dincluded.adapters=coverage,complexity,dependency</included.adapters>
</properties>
<argLine>-javaagent:serenity/serenity.jar -Xms512m -Xmx1024m ${included.packages} ${included.adapters}</argLine>

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

  1. ^ JaCoCo Mission
  2. ^ Patroklos Papapetrou (19 December 2012). "Code Coverage Tools (JaCoCo, Cobertura, Emma) Comparison in Sonar". Only Software matters. Retrieved 3 March 2013.
  3. ^ "Measure Coverage by Integration Tests with Sonar – Updated". Archived from the original on 2013-02-23. Retrieved 2013-03-01.
  4. ^ a b "Code Coverage". IntelliJ IDEA 12.0 Web Help. JetBrains. Archived from the original on 26 April 2013. Retrieved 3 March 2013.
  5. ^ EclEmma, Eclipse code coverage plugin
  6. ^ Jenkins JaCoCo Plugin
  7. ^ "NetBeans JaCoCo support". Archived from the original on 2012-05-31. Retrieved 2013-02-22.
  8. ^ Gradle JaCoCo Plugin
  9. ^ Gulati & Sharma 2017, pp. 99–103, Chapter §6 Integrating Tools - Build Tools - Gradle.
  10. ^ Maven JaCoCo Plugin
  11. ^ Gulati & Sharma 2017, p. 115, Chapter §6 Integrating Tools - Build Tools - Maven Extension.
  12. ^ JaCoCo integration in Visual Studio Team Services
  13. ^ JaCoCo integration in TeamCity
  14. ^ Jacoco is used by STAMP DSpot tool as a test selector (seen as a fitness) to select tests that increase the coverage and have unique executed path
  15. ^ OpenClover - About us
  16. ^ Testwell CTC++ supports all coverage levels
  17. ^ Testwell CTC++ supports all compilers
  18. ^ "Why does Clover use source code instrumentation?"
  19. ^ Test Optimization
  20. ^ "Atlassian Clover is now open source". atlassian.com. 11 April 2017.
  21. ^ "atlassian/clover". bitbucket.org.
  22. ^ EMMA code coverage files on SourceForge.net
  23. ^ Expert Spring MVC and Web Flow; By Seth Ladd, Darren Davison, Steven Devijver, Colin Yates, p. 289

Citations

Read other articles:

2012 2022 Élections législatives de 2017 en Savoie 4 sièges de députés à l'Assemblée nationale 11 et 18 juin 2017 Type d’élection Élections législatives Campagne 22 mai au 10 juin12 juin au 16 juin Corps électoral et résultats Inscrits 310 455 Votants au 1er tour 147 614   47,55 %  10,7 Votes exprimés au 1er tour 144 890 Votes blancs au 1er tour 1 989 Votes nuls au 1er tour 735 Votants au 2d tour 128 416   41,36 % Vote...

 

العلاقات الجزائرية الكولومبية الجزائر كولومبيا   الجزائر   كولومبيا تعديل مصدري - تعديل   العلاقات الجزائرية الكولومبية هي العلاقات الثنائية التي تجمع بين الجزائر وكولومبيا.[1][2][3][4][5] مقارنة بين البلدين هذه مقارنة عامة ومرجعية للدولتين: �...

 

Kartika Airlines IATA ICAO Kode panggil 3Y KAE KARTIKA Didirikan2001Berhenti beroperasi2010PenghubungBandar Udara Halim Perdanakusuma Bandar Udara Minangkabau Bandar Udara Sultan HasanuddinArmada6Tujuan5Kantor pusatJakarta, IndonesiaSitus webkartika-airlines.com Kartika Airlines di Bandar Udara Internasional Polonia, Medan, pada Desember 2006. Boeing 737-200 Advanced Kartika Airlines di Bandar Udara Internasional Polonia. (2006) Kartika Airlines adalah sebuah maskapai penerbangan bertarif ren...

Music festival in Canberra, Australia The National Folk Festival (NFF) is a longstanding, Australian family friendly celebration of all aspects of folk music and culture. It is held every year at Easter in the national capital, Canberra. Winner of many awards, such as National Qantas Australian Tourism Award for Best Festival in 2009, it features 15-20 venues with vibrant world-class artists, 'blackboard' opportunities, workshops, craft, bars and cafes and food. First held in Melbourne in 196...

 

Синелобый амазон Научная классификация Домен:ЭукариотыЦарство:ЖивотныеПодцарство:ЭуметазоиБез ранга:Двусторонне-симметричныеБез ранга:ВторичноротыеТип:ХордовыеПодтип:ПозвоночныеИнфратип:ЧелюстноротыеНадкласс:ЧетвероногиеКлада:АмниотыКлада:ЗавропсидыКласс:Пт�...

 

Pour les articles homonymes, voir Bade et Wurtemberg. État du Bade-Wurtemberg Land Baden-Württemberg Armoiries Drapeau du Bade-Wurtemberg Localisation du Bade-Wurtemberg (en vert foncé) à l'intérieur de l'Allemagne. Administration Pays Allemagne Capitale Stuttgart Ministre-président Winfried Kretschmann (Grüne) ISO 3166-2 DE-BW Démographie Gentilé Badois-Wurtembergeois Population 11 124 642 hab. (31/12/2021[1]) Densité 311 hab./km2 Rang 3e PIB (2010)PIB/hab...

Grand Prix São Paulo 2023 Lomba ke-20 dari 22 dalam Formula Satu musim 2023← Lomba sebelumnyaLomba berikutnya → Tata Letak Autódromo José Carlos Pace.Detail perlombaan[1]Tanggal 5 November 2023Nama resmi Formula 1 Rolex Grande Prêmio de São Paulo 2023Lokasi Autódromo José Carlos PaceSão Paulo, BrasilSirkuit Fasilitas balapan permanenPanjang sirkuit 4.309 km (2.677 mi)Jarak tempuh 71 putaran, 305.879 km (190.064 mi)Cuaca Sebagian berawanPenonton 267,000&...

 

本條目存在以下問題,請協助改善本條目或在討論頁針對議題發表看法。 此條目需要編修,以確保文法、用詞、语气、格式、標點等使用恰当。 (2013年8月6日)請按照校對指引,幫助编辑這個條目。(幫助、討論) 此條目剧情、虛構用語或人物介紹过长过细,需清理无关故事主轴的细节、用語和角色介紹。 (2020年10月6日)劇情、用語和人物介紹都只是用於了解故事主軸,輔助�...

 

Martin BormannMartin Bormann pada tahun 1934 Menteri dari NSDAPMasa jabatan30 April – 2 Mei 1945Pendahulupertama kali dibentukPenggantiTidak adaKepala ParteikanzleiMasa jabatan12 Mei 1941 – 2 Mei 1945PendahuluRudolf Hess (sebagai Deputi Führer)PenggantiTidak adaSekretaris Pribadi FührerMasa jabatan12 April 1943 – 30 April 1945Sekretaris Pribadi Deputi FührerMasa jabatanJuli 1933 – 12 Mei 1941ReichsleiterMasa jabatanOktober 1933 – 2 Mei...

Jalur trem nostalgia di IstanbulAtas: Dua trem warisan di sisi Eropa, di Jalur Trem Nostalgia Taksim-Tünel (T2).Bawah: Trem warisan di sisi Asian side, on the T3 circular nostalgia tramway.InfoWilayahIstanbul, TurkiJenisTrem WarisanJumlah jalur2 (1 sisi Eropa, 1 sisi Asia)Jumlah stasiun5 (T2)10 (T3)[1]Situs webT3 Nostalgia TramwayOperasiDimulai29 Desember 1990 (T2)[2][3]1 November 2003 (T3)[1][3]OperatorIETT (T2) İstanbul Ulaşım (T3)TeknisPanjang si...

 

This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: List of loughs of County Mayo – news · newspapers · books · scholar · JSTOR (November 2021) (Learn how and when to remove this message) County Mayo (shaded dark green) This is a list of loughs in County Mayo, Ireland.[1] Ballin Lough Ballymore Lough Be...

 

1987 UK local government election Map of the results for the 1987 Solihull council election. The 1987 Solihull Metropolitan Borough Council elections were held on Thursday, 7 May 1987, with one third of the council to be elected. The Conservatives retained control of the council. Voter turnout was 43.2%[1][2] Election result Solihull Local Election Result 1987 Party Seats Gains Losses Net gain/loss Seats % Votes % Votes +/−   Conservative 11 1 1 0 64.7 51.0 34...

عزيز بودربالة عزيز بودربالة يتحدث مع لالة مولاتي، 12 فبراير 2018 معلومات شخصية الميلاد 26 ديسمبر 1960 (العمر 63 سنة)الدار البيضاء  الطول 1.78 م (5 قدم 10 بوصة) مركز اللعب وسط الجنسية المغرب  المسيرة الاحترافية1 سنوات فريق م. (هـ.) 1977–1984 الوداد الرياضي – (–) 1984–1988 سيون 88 (25) 1...

 

Questa voce o sezione sull'argomento centri abitati dell'Emilia-Romagna non cita le fonti necessarie o quelle presenti sono insufficienti. Puoi migliorare questa voce aggiungendo citazioni da fonti attendibili secondo le linee guida sull'uso delle fonti. Pievepelagocomune Pievepelago – Veduta LocalizzazioneStato Italia Regione Emilia-Romagna Provincia Modena AmministrazioneSindacoCorrado Ferroni (lista civica di centro-sinistra) dal 7-6-2009 (3º mandato d...

 

Defunct low-cost airline of Japan (2011–2013; 2014–2020) This article is about the company established in 2011 and re-established in 2014. For the All Nippon Airways joint venture, see Vanilla Air. AirAsia Japanエアアジア・ジャパンEāajia Japan IATA ICAO Callsign DJ WAJ WING ASIA FoundedPart 1: 1 July 2011 (2011-07-01)Part 2: 1 July 2014 (2014-07-01)Commenced operationsPart 1: 1 August 2012 (2012-08-01)Part 2: 29 October 201...

Third Division 1982-1983 Competizione Third Division Sport Calcio Edizione 56ª Organizzatore Football League Date dal 28 agosto 1982al 14 maggio 1983 Luogo  Inghilterra Galles Partecipanti 24 Formula girone all'italiana A/R Risultati Vincitore Portsmouth(3º titolo) Altre promozioni Cardiff CityHuddersfield Town Retrocessioni ChesterfieldDoncaster RoversReadingWrexham Statistiche Miglior marcatore Kerry Dixon (26) Incontri disputati 552 Gol segnati 1 617 (2,...

 

Anfiteatro delle Tre GallieCiviltàRomana Stilearchitettura romana EpocaI secolo d.C. - III secolo d.C. LocalizzazioneStato Francia DipartimentoMetropoli di Lione DimensioniLarghezzaarena: 67 m x 42 m ScaviData scoperta1834 Date scavi1860 1961-67 1968-69 1971-72 1976-78 ArcheologoAmable Audin AmministrazionePatrimonioCittà storica di Lione EnteComune di Lione Visitabileno (ma visibile dall'esterno) Sito webwww.lyon-france.com/Que-faire/Culture-loisirs/Sites-monuments-historiques/Monumen...

 

Process that allows organizations to concentrate limited resources on greatest opportunities This article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these template messages) This article is written like a personal reflection, personal essay, or argumentative essay that states a Wikipedia editor's personal feelings or presents an original argument about a topic. Please help improve it by rewriting it in an encyclopedic st...

International border Border tripoint between Italy, Slovenia and Austria, at an altitude of 1,500 metres (4,900 ft) Border tripoint between Austria, Hungary, and Slovenia The Austrian–Slovenian border is a 330-kilometre (210 mi)[1] land border between the Republic of Austria and the Republic of Slovenia. History Until 1991, it was the border between Austria and Yugoslavia. When Slovenia gained independence in 1991, it became the Austrian–Slovenian border. References ^ Bo...

 

2009 single by Michael BubléHold OnSingle by Michael Bubléfrom the album Crazy Love B-sideLet It Snow, Let It Snow, Let It Snow (Live)ReleasedDecember 11, 2009 (U.K.)January 24, 2010 (U.S.)Recorded2009GenrePopLength4:05Label143 RecordsRepriseSongwriter(s)Michael BubléAlan ChangAmy Foster-GilliesProducer(s)Bob RockMichael Bublé singles chronology Haven't Met You Yet (2009) Hold On (2009) Baby (You've Got What It Takes) (2010) Licensed audioHold On on YouTube Hold On is a song by Canadian c...