Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

./gradlew jacocoTestReport does not print coverage #18

Open
schwaerz opened this issue May 5, 2023 · 1 comment
Open

./gradlew jacocoTestReport does not print coverage #18

schwaerz opened this issue May 5, 2023 · 1 comment

Comments

@schwaerz
Copy link

schwaerz commented May 5, 2023

I don't know why, but the jacocoTestReport task is the only task which does not print any coverage information. I tried with different configuration settings.

I can use the following workaround (using the settings in my build.gradle as written below):

./gradlew build
./gradlew jacocoTestReport
./gradlew build

Current settings in build.gradle look like:

jacoco {
    toolVersion = "0.8.2"
    // reportsDir = file("$buildDir/customJacocoReportDir")
}

consoleReporter {
    jacoco {
        reportAfterBuildFinished true
        onlyWhenCoverageTaskExecuted false
        reportFile new File("${project.buildDir}/reports/jacoco/test/jacocoTestReport.xml")
        coverageTaskName 'jacocoTestReport'
    }
}

jacocoTestReport {
    dependencies {
        test
    }
    reports {
        xml.enabled true
        csv.enabled false
        html.destination file("${buildDir}/jacocoHtml")
    }
}

jacoco {
    applyTo run
}

task applicationCodeCoverageReport(type:JacocoReport){
    executionData run
    sourceSets sourceSets.main
}
  • The first call to build will show a coverage of 0%, as no report has been generated yet
  • The call to jacocoTestReport will not output any coverage
  • The 2nd call to build will pick up the report as generated by jacocoTestReport and display the coverage:
localuser@localhost:~/repositories/butler$ ./gradlew build
...
Coverage summary:
butler:   0.0%

BUILD SUCCESSFUL in 23s
10 actionable tasks: 10 executed
localuser@localhost:~/repositories/butler$ ./gradlew jacocoTestReport

BUILD SUCCESSFUL in 1s
2 actionable tasks: 1 executed, 1 up-to-date
localuser@localhost:~/repositories/butler$ ./gradlew build

Coverage summary:
butler:  77.5%

BUILD SUCCESSFUL in 729ms
10 actionable tasks: 1 executed, 9 up-to-date
localuser@localhost:~/repositories/butler$ ./gradlew jacocoTestReport
@kmackinnon
Copy link

Downgrading to v0.5.0 fixed this for me in a multi-project build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants