Hello Team !
I have multi-module, multi-language repo which I am scanning using SonarScanner 4.3. On Sonar dashboard, I am not able to show unit test count of my Junit5 test.
As per my debugging, understood that I have to provide Junit XML report to sonar.junit.reportPaths= property to show the count.
I do not want to provide hard coded value to this property. So option which I am exploring is if somehow if I can aggregate all the Junit5 XML report under repository at root project level then I can just point the sonar.junit.reportPaths= property to that location.
My Java build is via Gradle and I do see following option which is for HTML report and not for XML reports.
task junit5TestReport(type: TestReport) {
destinationDir = file("$buildDir/reports/tests/test")
// Include the results from the `test` task in all subprojects
reportOn subprojects*.test
}
test.finalizedBy(junit5TestReport)
Well, copying the files from other projects tasks like this is unsafe and very bad and shouldn’t be done.
If you really need the files collected, you should use safe publication between projects using configurations selected by attributes. Actually the test-report-aggregation plugin does exactly that, so you could just apply it and use the configuration it added to get all the result files.
But actually specifically for the case OP asked about, it is not necessary at all.
The Sonar Gradle scanner defines the repot paths per project of the multi-project build and then does the aggregation itself, no need to copy together anything or to configure all paths in one place.