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
11
votes
1 answer

How do I generate a JaCoCo report for a JAR file?

We are trying to report code coverage of tests against a pre-packaged JAR file using JaCoCo. To do this we start the JAR file using java -jar with the additional…
Peter Becker
  • 8,795
  • 7
  • 41
  • 64
11
votes
1 answer

How to set jacoco code coverage levels to module in gradle

I'm using gradle 4.3.1 with the jacoco plugin and I am able to ensure a certain level of code coverage in a a multi module project. This works great when I set the element to CLASS or PACAKAGE, but I'm stumped on how to get it work for the module.…
Tristan
  • 279
  • 5
  • 21
11
votes
3 answers

Cross-module code coverage with jacoco and gradle multi-module project

We use gradle 3.3 and jacoco tool verson 0.7.6.201602180812. We have a gradle multi-project like this: parent prod1 prod2 prod3 int-test We use unit-tests testing the project sources and jacoco on all child-projects producing test.exec files.…
Michael Zöller
  • 125
  • 1
  • 1
  • 8
11
votes
5 answers

Eclipse - Java - Gradle is skipping jacocoTestReport

Project structure: src/main/java src/main/resources src/test/java Gradle version : 2.2.1 Here is my build.gradle apply plugin: 'java' apply plugin: 'eclipse' apply plugin: 'jacoco' version = '1.0' sourceCompatibility…
Kishore
  • 317
  • 2
  • 4
  • 17
11
votes
2 answers

Execute task with build task

I have a traditional java project using gradle build system. I would like to add jacoco code coverage report generation. So I applied jacoco plugin and everything works as expected when I call gradle build jacocoTestReport I was wondering how can I…
sockeqwe
  • 15,574
  • 24
  • 88
  • 144
11
votes
3 answers

Jenkins jacoco plugin empty report

I have a project where I use Jacoco to calculate the code coverage. I use maven configuration like here…
YLombardi
  • 1,755
  • 5
  • 24
  • 45
11
votes
0 answers

Jacoco misses all coverage if @PrepareForTest is used

I've run into an interesting problem with Jacoco reporting 0% coverage for a class under unit test if @PrepareForTest is used. Long story short, my unit test is using a combination of @RunWith(PowerMockRunner.class) and…
Michael Remijan
  • 687
  • 7
  • 22
10
votes
1 answer

Android: Jacoco code coverage is not generating after gradle upgrade to 7.0.x & jdk 11

Android: Jacoco code coverage is not generating after gradle upgrade to 7.0.x & jdk 11 with testCoverageEnabled true. It is working perfect with gradle 4.2.x & jdk 8. I tried removing testCoverageEnabled true with gradle 7.0.x & it again started…
10
votes
2 answers

Always EOFException with Jacoco exec file

I tried to generate Jacoco reports for Sonarqube. Generating the file jacoco.exec works but using it for Sonarqube OR in Eclipse's EclEmma results in an EOFException (so both implementations are crappy or the generated file is the problem). There…
Milgo
  • 2,617
  • 4
  • 22
  • 37
10
votes
1 answer

How to cover unnecessary null check generated by Kotlin?

Consider the following minimal Kotlin example: fun someWrapper(supplier: () -> U): () -> (U) { return { supplier() } } fun foo(taskExecutor: TaskExecutor): Int { val future = CompletableFuture.supplyAsync(someWrapper { 42 },…
BKE
  • 573
  • 2
  • 16
10
votes
2 answers

Use JaCoCo in Android Project with Gradle

I have an android project with Gradle 5.1.1 I want to use JaCoCo to generate HTML reports about test code coverage. I tried to follow the instructions in some articles, but all of my attempts led to errors. All that worked for me is applying plugin…
Igor Lopatinkiy
  • 103
  • 1
  • 1
  • 5
10
votes
2 answers

Gradle Jacoco plugin not generating reports

Java 8 and Gradle 4.6 here. I'm trying to configure my Gradle build to use the Jacoco Plugin but am having some difficulty. I've already got it working with Checkstyle and Findbugs, such that running ./gradlew clean build invokes the Checkstyle and…
hotmeatballsoup
  • 385
  • 6
  • 58
  • 136
10
votes
2 answers

Jacoco how to correctly exclude package

I am using the Jacoco Maven plugin version 0.8.1 (With Java 8 / Maven 3.1.0). Cannot get Jacoco to work with path exclusions. I would like to exclude these packages : my.package.model my.package.exception What I tried :
cactuschibre
  • 1,908
  • 2
  • 18
  • 36
10
votes
4 answers

How to get test coverage or ignore by Jacoco for Kotlin data classes

Jacoco shows 0% coverage for Kotlin's data classes. How to configure it to measure coverage or ignore data classes at all?
tse
  • 5,769
  • 6
  • 38
  • 58
10
votes
1 answer

Is prepare-agent goal is necessary in jacoco-maven-plugin?

In My project, if I write pom like this: ... org.jacoco jacoco-maven-plugin 0.7.9
jianfeng
  • 2,440
  • 4
  • 21
  • 28