hey folks, anyone knows if it's possible to genera...
# community-support
m
hey folks, anyone knows if it's possible to generate a single jacoco aggregated report for different kinds of test suites? e.g instead of
report.getTestType().convention(TestSuiteType.UNIT_TEST);
I would like to use a set of test suite types
v
Not out-of-the-box, but you can make it possible, I did it in the past to aggregate over all test types.
m
using the aggregation plugin?
v
Yep, and "some" additional configuration.
I basically invented an "all" test type by creating a consumable configuration for the coverage data elements for the "all" type, `configureEach`ed all `JvmTestSuite`s to add the coverage data to this configuration additionally, and then registered a
JacocoCoverageReport
for the "all" test type.
m
I see, I will investigate that, thanks
n
Would that solution be shareable by any chance (in an ideal world, as a contribution to the plugin)? We've been manually crafting a separate coverage report using cross-project configuration (😱) and SonarQube was still being difficult about it (it gets confused if multiple xml report files are available in a multi-module project).
v
Theoretically yes. But I don't know whether it would be accepted as the intention seems to be to only aggregate over the same type. 🤷‍♂️
m
I'm not sure if it's the intention or an oversight
n
Pity.. again something SonarQube doesn't like. You can only send 1 coverage report. It ignores or fails on multiple reports or attempts to update coverage data for a scan 😞
v
Iirc you can give SQ multiple but you have to do so as one bunch
n
We've tried, but it seems there can't be any overlap in the coverage data. The moment 2 reports claim to add coverage data for the same module, it causes loss of information (I don't recall the exact scope, either it ignores all but the 1st report, or just all for that module).
so that breaks the use case of multiple test suites on the same module
v
Ah, right, I there configure one JaCoCo task to report on all test tasks and then configure its XML report for SonarQube and that per project.
But I thought that was just legacy dept as in the past you could only configure one report while now you can give multiple to
sonar.coverage.jacoco.xmlReportPaths
Also the docs suggest that multiple should work. If it does not work properly, that's probably a SQ bug then
n
It's been a few versions of SQ since I've reviewed our setup, so perhaps the situation has improved. But it's so fickle, that any change is scary to be honest 😛
v
Same same 😄
j
You can also combine things on the consumer (aggregation) side. E.g.:
Copy code
// Integrate INTEGRATION_TEST results into the aggregated UNIT_TEST coverage results
tasks.testCodeCoverageReport {
    executionData.from(
        configurations.aggregateCodeCoverageReportResults.get()
                .incoming.artifactView {
                    lenient(true)
                    withVariantReselection()
                    attributes {
                        attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.VERIFICATION))
                        attribute(TestSuiteType.TEST_SUITE_TYPE_ATTRIBUTE, objects.named(TestSuiteType.INTEGRATION_TEST))
                        attribute(VerificationType.VERIFICATION_TYPE_ATTRIBUTE, objects.named(VerificationType.JACOCO_RESULTS))
                        attribute(ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE, ArtifactTypeDefinition.BINARY_DATA_TYPE)
                    }
                }.files
    )
}
👀 1
❤️ 1