Unwanted tasks added as dependencies to JaCoCo task
See original GitHub issueIn our project (using JUnit 4) we define a jacocoTestReport
Gradle task:
task jacocoTestReport(type: JacocoReport, dependsOn: ["testInternalDebugUnitTest"]) {
group = "Reporting"
description = "Generate Jacoco coverage reports"
reports {
xml.enabled = true
html.enabled = true
xml.destination file("${buildDir}/reports/jacoco/test/jacocoTestReport.xml")
}
sourceDirectories.from = files([mainSrc])
classDirectories.from = files([debugTree], [kotlinClasses])
executionData.from = fileTree(dir: "$buildDir", includes: ["**/**/*.exec", "**/**/*.ec"])
}
And when using JUnit 4 and checking the dependency graph we see it is indeed dependent on testInternalDebugUnitTest
:
:app:jacocoTestReport
\--- :app:testInternalDebugUnitTest ...
BTW, we have two flavors, Internal
and Production
.
When I add the JUnit 5 plugin, however, the task is now dependent on all flavors of jacocoTestReport
, which are dependent on their respective flavor of unit test task:
:app:jacocoTestReport
+--- :app:jacocoTestReportInternalDebug
| \--- :app:testInternalDebugUnitTest ...
+--- :app:jacocoTestReportInternalRelease
| \--- :app:testInternalReleaseUnitTest ...
+--- :app:jacocoTestReportProductionDebug
| \--- :app:testProductionDebugUnitTest ...
+--- :app:jacocoTestReportProductionRelease
| \--- :app:testProductionReleaseUnitTest ...
\--- :app:testInternalDebugUnitTest *
Which results in our unit tests running once for each flavor combination, when we only want to run them for InternalDebug
.
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:17 (6 by maintainers)
Top Results From Across the Web
The JaCoCo Plugin - Gradle User Manual
Define dependencies between code coverage reports and test execution ... The JaCoCo plugin adds a JacocoTaskExtension extension to all tasks of type Test....
Read more >gradle - Report is not getting added as part of build phase
Added JACOCO HTML report in my Gradle build for java project. But Report was not getting added as part of build phase, need...
Read more >JaCoCo - Change History
Branches added by the Kotlin compiler for open functions with default arguments ... added in version 0.6.1 into jacocoant.jar that contains all dependencies...
Read more >Android+Kotlin Code coverage with Jacoco, Sonar and Gradle ...
Firstly, you will want to add Jacoco plugin to your project. ... from dependencies (for instance by not depending on the task and...
Read more >Separate Gradle Tasks for Unit and Integration Tests - Inspeerity
Most developers know how painful is accidental, unnecessary run of tests using the ... We need to add dependencies to our integration tests...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m glad it turned out well for you in the end! Closing this ticket. 🙏
The only side effect is that the variant-specific Jacoco tasks aren’t generated automatically - other than that, nothing else comes to mind. That being said, this integration with Jacoco stems from a very old requirement, before there was native support for JUnit 5 in Gradle. Now that the first-party tasks run it well, it might be time to deprecate the integration slowly…
Glad to hear that it worked out eventually, and thanks @nuhkoca for chiming in, much appreciated! As for questions related to JUnit 5 execution performance on CI, please raise potential questions on their repo directly 🙏