How do I run generate all jacoco reports?

If you have multiple test tasks then the jacoco plugin will add a report task for each test task. These report tasks are finalised by the buildDashboard task so if they run then the dashboard will be updated. However the report tasks do not finalise the test task so I can see no obvious way to make them run when the tests run.

Is there a simple way to do this? if not, it would be nice if the plugin could be configured to do this automatically

I think the idea was to keep test execution and report generation decoupled by default. Can’t you add the necessary dependencies yourself?

I can (and am), it just seems like it would be easier to do from the plugin rather than having to go and discover the reports that can be run and then add a task to draw them all together.

How would you do this without coupling test execution to report generation for everyone?

provide a configuration option on the plugin to let you choose whether to link it or not

What exactly would the configuration option do?

Add the report task as a finaliser of the task that produces the jacoco.exec

If you want to run tests and produce reports, run the report tasks. If you only want to run tests, run the test tasks. How would you like to see this improved? Maybe the design decision stems from not having a way to run tests without recording coverage (once the ‘jacoco’ plugin is applied). So the author at least wanted to provide a way to run tests without generating coverage reports.

this is fine when you have a default setup (1 test task per project called test and hence 1 report task jacocoTestReport) but when you have n test tasks and hence n report tasks then there is no simple shortcut to run them all without wiring them together yourself. This becomes important in a CI environment with a variety of projects running the same core build as it lets you minimise the variance in the configuration so I just have a TeamCity template that runs gradlew release jacocoCompleteReport and I get every reports generated in 1 go. This doesn’t seem like an uncommon use case to me.

Why isn’t ‘task jacocoCompleteReport(dependsOn: tasks.withType(JacocoReport))’ good enough to achieve this? The report tasks should already be wired to the test tasks, no?