Questions tagged [jacoco]

JaCoCo a coverage analysis tool. It runs as a JVM Agent and therefore does not require offline instrumentation.

JaCoCo is an EPL-licensed, open-source code coverage analysis tool. It runs as a JVM Agent and therefore does not require offline instrumentation.

Compared to Cobertura, it has lower runtime overhead but less precision. It is unable to record hit counts, it only records red/green, however it can show coverage on class, method, line, complexity, branch and instruction level. It also has the ability to merge the results of multiple analyses when generating a report.

QuickLinks:

Related Tags:

JaCoCo is the successor of the EclEmma Eclipse plugin for the Emma coverage tool. If a search through -tagged questions doesn't help, try searching for the tag.

The tag is used for general topics related to code coverage measurement.

1891 questions
17
votes
3 answers

Getting code coverage of my application using JaCoCo Java agent on Tomcat

I want to measure the code coverage of integration tests using the JaCoCo and Sonar tools. For that, I start my Tomcat 5.5 configured with the JaCoCo agent in order to get the dump file from JaCoCo. Thus, I set the JAVA_OPTS for that: set…
Romain Linsolas
  • 79,475
  • 49
  • 202
  • 273
17
votes
3 answers

How to create a badge with test coverage (jacoco) on github (actions)

In spring project, I use jacoco plugin to measure test coverage. I see the html report like below: Now I would like to add a badge to github project with this percentage, something like this: Any idea how can I combine jacoco with github actions?
tostao
  • 2,803
  • 4
  • 38
  • 61
17
votes
3 answers

Execution data for class does not match + Jacoco

I'm using Jacoco to find the code coverage of unit tests with ANT but the report isn't generated and I get this error sequence: [jacoco:report] Loading execution data file C:\JUnit\apache-ant-1.10.1\jacoco.ex ec [jacoco:report] Writing bundle…
xmacz
  • 394
  • 1
  • 5
  • 14
17
votes
3 answers

No coverage report for inlined Kotlin methods

Kotlin functions marked with inline keyword are, well, inlined during the compilation and it seems that code coverage tools (like JaCoCo) fail to properly calculate code coverage. What is the usual approach to overcoming this issue? Is there a way…
Czyzby
  • 2,999
  • 1
  • 22
  • 40
17
votes
3 answers

continue jacoco code coverage report after fail test case

Code coverage report not generated when Test case failed in android studio using Jacoco plugin.How to skip failed test case and generate code coverage report.
Hardik Bambhania
  • 1,732
  • 15
  • 25
17
votes
6 answers

Tomcat7 Maven Plugin and JaCoCo

Is there any way to get code coverage using JaCoCo with the tomcat7-maven-plugin embedded instance? The jacoco-maven-plugin is configured in my WAR's POM to instrument my unit tests, but I'm not sure how to attach the jacoco agent to the embedded…
shelley
  • 7,206
  • 4
  • 36
  • 63
17
votes
3 answers

Missing branches when using assertTrue instead of assertNull

In Java/Junit, I need to test for null with some object. There are a variety of ways I can test a condition but I have been using assertTrue for most of my tests. When I check for nulls in an assertTrue, EclEmma states that it is only testing one…
user29053
16
votes
2 answers

Changing enabled to required throws an error in gradle

Changing enabled to required throws an error in gradle 7.5 > Configure project : The Report.enabled property has been deprecated. This is scheduled to be removed in Gradle 8.0. Please use the required property instead. See…
Rpj
  • 5,348
  • 16
  • 62
  • 122
16
votes
3 answers

How to fix 'Could not write standard input to Gradle Test Executor 1' error in Java

I'm trying to compline my code(on new branch) but I got the error after I fix and updated build.gradle but before I run that code my code(on old branches) is still working. So I checkout master branch I still get that error Here is my build.gradle…
16
votes
3 answers

jacocoTestReport task not being generated

Android Studio 3.1 Canary 8 Build #AI-173.4529993, built on January 6, 2018 JRE: 1.8.0_152-release-1024-b01 amd64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o Linux 4.14.14-300.fc27.x86_64 I am trying to use the jacoco to generate code…
ant2009
  • 27,094
  • 154
  • 411
  • 609
16
votes
4 answers

Code coverage in maven build - Skipping JaCoCo execution due to missing classes directory

I am able to get code coverage working fine if I have a single project but now I have a multi module project. My application is built in the api project and all my integration tests are running in a separate project which uses the artefact built as…
berimbolo
  • 3,319
  • 8
  • 43
  • 78
16
votes
1 answer

how to interpret the jacoco.xml file?

I am using the JACOCO tool in Maven project. It creates code coverage XML file "jacoco.xml". As I'm going to parse this xml I need to know the meaning of some attributes in the xml file. xml contains following elements:
Chathura Wijeweera
  • 289
  • 1
  • 2
  • 9
16
votes
2 answers

Find which test covers which line jacoco

I'm running integration test on a huge code base. In coverage report I want to know which test covered a certain line in code. Is there anyway of doing it with jacoco?
Ahmad.Masood
  • 1,289
  • 3
  • 21
  • 40
15
votes
1 answer

How to add Java compile-time Custom annotation to Protobuf generated code

I use gRPC framework with Proto 3. We have a java code coverage tool Jacoco which scans java byte code for java "annotation" @Generated in compiled classes and if it has one, it skips that java class from coverage. But Proto-compiler adds this…
Ivan Voroshilin
  • 5,233
  • 3
  • 32
  • 61
15
votes
5 answers

How to exclude a line from jacoco code coverage?

How would i exclude inputStream.close() from jacoco code coverage, in pom.xml or in the java code? public void run() { InputStream inputStream = null; try { inputStream = fileSystem.newFileInputStream(file); } finally { …
nommer
  • 2,730
  • 3
  • 29
  • 44