Sonar Jacoco for Kotlin Setup not generating code coverage

前端 未结 2 1824
醉话见心
醉话见心 2021-02-07 05:47

I\'m trying to do Sonar Setup with Jacoco for Kotlin to generate Code Coverage report but it\'s not showing any code coverage. While checking Sonar Console it showing following

相关标签:
2条回答
  • 2021-02-07 06:04

    If you're using the android test orchestrator this is likely the problem.

    I had the same issue today and after disabling the android test orchestrator the coverage is working again.

    Bug report: https://issuetracker.google.com/issues/72758547

    I'm not sure how Android Kotlin builds are configured, but in my Android Java build.gradle I had to comment out the test orchestrator like so:

    android {
    ...
        testOptions {
            // temporarily disable the orchestrator as this breaks coverage: https://issuetracker.google.com/issues/72758547
            //execution 'ANDROID_TEST_ORCHESTRATOR'
        ...
        }
    }
    
    0 讨论(0)
  • 2021-02-07 06:23

    There are few things you need to do to make it work for kotlin.

    • Ensure your sonarqube > 7.5
    • If your sonarqube ver < 7.5, have the admin install sonar-jacoco plugin. Check the plugin compatibility version if sonarqube < 5.5.
    plugins {
        id "jacoco"
        id "org.sonarqube" version "2.7.1"
    }
    

    Follow this url: https://community.sonarsource.com/t/coverage-test-data-importing-jacoco-coverage-report-in-xml-format/12151

    Add properties in your build.gradle for it to search for jacoco results.

    property 'sonar.coverage.jacoco.xmlReportPaths', "${buildDir}/reports/jacoco/test/jacocoTestReport.xml"
    

    Follow this url for properties: https://docs.sonarqube.org/7.5/analysis/analysis-parameters/

    0 讨论(0)
提交回复
热议问题