sonar.coverage.jacoco.xmlReportPaths not showing code coverage but the deprecated sonar.jacoco.reportPaths shows code coverage

Bug Statement:
I am using sonar.jacoco.reportPaths for reporting code coverage on SonarQube. But when I use the same with sonar.coverage.jacoco.xmlReportPaths then, it is now showing code coverage on Sonarqube server. As the previous property is deprecated, I need to move on new one. But with that code coverage is not working.

Below are the plugins and version used to report the code coverage.
SonarQube version is Version 7.9.1
Android Sonar plugin is org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.7.1
Jococo android plugin is com.dicedmelon.gradle:jacoco-android:0.1.4
Jococo toolchain tool version is 0.8.3

Below are the property used

        sonarqube {
        properties {
            // Root project information
            property 'sonar.projectKey', 'AppNameAndroid'
            property 'sonar.projectName', 'AppName-Android'
            // Some properties that will be inherited by the modules
            property 'sonar.sources', 'src/main/java/com/app_name/app'
            property 'sonar.sourceEncoding', 'UTF-8'
            property 'sonar.exclusions', '**/*.html,**/*.css,**/*.png,**/*.jpg,**/*.JPG,**/io/ionic*,**/io/ionic**,**/io/ionic**/*.java,**/org/*,**/org/**,**/org/**/*.java,**/cordova/*,**/cordova/**,**/cordova/**/*.java,**/android/*,**/android/**,**/android/**/*.java,**/apache/commons/**'
            property 'sonar.scm.provider', 'git'
            property 'sonar.java.source', '1.8'
            property 'sonar.tests', ["src/test/java"]
            property 'sonar.java.coveragePlugin', "jacoco"
            property 'sonar.coverage.exclusions', '**/*.html,**/*.css,**/*.png,**/*.jpg,**/*.JPG,**/io/ionic*,**/io/ionic**,**/io/ionic**/*.java,**/org/*,**/org/**,**/org/**/*.java,**/cordova/*,**/cordova/**,**/cordova/**/*.java,**/android/*,**/android/**,**/android/**/*.java,**/apache/commons/**'
            // Below property needs to be use very soon
            //property 'sonar.coverage.jacoco.xmlReportPaths', "build/reports/jococo/jococoTestDevReleaseUnitTestReport/jacocoTestDevReleaseUnitTestReport.xml"
            property 'sonar.jacoco.reportPaths', "${project.buildDir}/jacoco/testDevReleaseUnitTest.exec"
            property 'sonar.junit.reportsPath', "${project.buildDir}/test-results/testDevReleaseUnitTest"

            property 'sonar.java.binaries', "${project.buildDir}/intermediates/javac/devRelease/compileDevReleaseJavaWithJavac/classes/com/visualogyx"
            property 'sonar.projectVersion', getFlavorVersionCode()

        }
    }

#bug: jococo xml report
#bug: jococo code-coverage issue

@Shreyash, do you create XML report during the build? Please have a look at the guide here how to do it [Coverage & Test Data] Importing JaCoCo coverage report in XML format

HI,
Thanks for your reply. Yes, I have created XML report and also assign that to the new sonar properly. Right now, it is commented on above post as If I uncomment it and upload the analysis then it is not showing code coverage.

Please help towards that. Thanks.

@saberduck
This is what I got when I use sonar.jacoco.reportPaths

image

Thanks.

This is what I got when I use sonar.coverage.jacoco.xmlReportPaths

image

I hope you got my point. Do let me know if you need any information for same.

You have to make sure that the data you are importing actually contain any coverage, I don’t think that the issue is in SonarQube, but that the report itself is not correct.

Try to create html report in addition to the XML one, and see if the numbers inside the report are correct.

@saberduck

I have done the same thing. But got same results as below in both the condition.

From the screenshot I see that total coverage is 0%, SonarQube is only going to display what’s in the report. You would need to fix your report to have the same numbers as before.

Try to pinpoint where the difference happens (which file/module) and troubleshoot why the coverage is missing in that particular locations.

@saberduck
Ok. But my pin point is, why code coverage report get changed with the single property, if I upload it to SonarQube. While the same report raised in local machine.

There is something get changed with that sonar property. I need proper guidance if I am defining it wrong.

Please update me for same.

Thanks.

@saberduck

Is there any luck to get the issue and provide a guideline to resolve it?
It would be great if you can check and update for the same.

Thanks.

hello,

you need to investigate and fix the XML report. The problem is not in SonarQube, SonarQube is only showing the data you are providing in the XML report.

@saberduck

I have raised the issue on Jacoco plugin repository for same. They are saying that the issue is from sonarQube, But not from thier end. Now, what should be consider here.

I feel like, the issue is from sonarQube only. Otherwise, how it get changed by changing deprecated flag and using new one.
Please review this and help to resolved it.

Looking to have more details in resolving this issue.
Thanks.

@saberduck

Hi, If you check the details given at below link, I found that the issue is from either configuration or from the SonarQube. Can you please check for same and help me for that.

Thanks.

@Shreyash, the issue is most likely in the configuration of your build. To fix it, it would require that you investigate how your build is creating coverage report and to understand where the difference arises.

Also, this is not just simple property change, to achieve the same results, you have to modify your build to compute the right data.

In this screenshot,
image

can you investigate, which lines are covered (which source files, which module) and how the coverage is obtained (where are the tests that provide that coverage, how are they launched)?

How do you create XML report? Can you share relevant configuration from your build?

OK Thanks.

I will look into it and will update you. FYI, I got an update from Jacoco plugin that I was using third party plugin for that, So I will probably change it and then will try it.

Thanks for your support. I will reach to you in case your attention is required in that.

Thanks.