Running jacocoReport

None of the above worked for me. What worked for me was the following

Add to the top of my build.gradle:

apply plugin: 'jacoco' // code coverage reports

Add the following as a 'task':

// Generate code coverage reports ... run with jacoco
jacocoTestReport{
    additionalSourceDirs = files(sourceSets.main.allJava.srcDirs)
    reports {
        xml.enabled false
        csv.enabled false
        html.destination "${buildDir}/reports/jacoco/html"
    }
    executionData = files('build/jacoco/test.exec')
}

Add the following to your gradle test task:

finalizedBy jacocoTestReport

Then I issued the following command:

gradle run test jacoco

The task will only run if coverage data is available. You can make sure of that by also running the test task.


Add the following at a top level to your build.gradle:

test {
 finalizedBy jacocoTestReport
}

This means that at the end of the test task the jacocoTestReport task should be run. You will receive your coverage analysis after run the tests.