0

I am using jacoco for Test coverage verification in a Java Library created with Gradle. I have set the verification rule to limit minimum coverage to 1.0 (100%). I have a few classes in my code which are not meeting the criteria. based on the unit-tests that I have written, I don't think I am missing any line of code.

on those lines, I was wondering if there is a was to make jacoco print out which lines are not getting covered by unit tests during the build process?

currently jacoco causes a build failure reporting the coverage ration for each files that didn't meet the bar but it does not provide any information on specific lines that were not covered.

AppleCiderGuy
  • 1,249
  • 1
  • 9
  • 16

1 Answers1

0

I was able to configure My Gradle-Groovy project to start generating Jacoco coverage reports by doing the following:

added jacoco plugin to buildscript in build.gradle

apply plugin: 'jacoco'

adding a custom configuration:

jacocoTestReport {
 dependsOn test
}

chaining jacocoTestReport to your test task

test {
  finalizedBy jacocoTestReport 
}

This ensures, report is always generated after tests run.

Note: if you have added both jacoco and java plugin, reports are automatically generated and stored at $buildDir/reports/jacoco/test in such a scenario, you can skip above steps.

AppleCiderGuy
  • 1,249
  • 1
  • 9
  • 16