Kotlin Unit Test result not showing on SonarQube 9.0.1 developer

Hi,

Versions:
SonarQube > Developer EditionVersion 9.0.1 (build 46107)
SonarScanner for Gradle plugin > 3.3

We developed Android App written in Kotlin, we can see code coverage but we are not able to get unit test numbers.

We follow the next steps:

  1. testStagingDebug [test for specific android variant]
  2. testStagingDebugUnitTestCoverage [custom task to run Jacoco]
  3. sonarQube
sonarqube {
    androidVariant 'stagingDebug'
    properties {
        property "sonar.projectName", "projectName"
        property "sonar.projectKey", "projectKey"
        property "sonar.sources", "src/main/java"
        property "sonar.tests", ["src/test/java"]
        property "sonar.sourceEncoding", "UTF-8"
        property "sonar.sources", "src/main/java"
        property "sonar.test.inclusions", "**/*Test*/**"
        property "sonar.exclusions", '**/*Test*/**,' +
            'build/**' +
            '*.json,' +
            '**/*test*/**,' +
            '**/.gradle/**,' +
            '**/*Generated.java,'+
            '**/R.class'
        property "sonar.java.coveragePlugin", "jacoco"
        property "sonar.junit.reportPaths", "${project.projectDir}/build/test-results/testStagingDebugUnitTest/"
        property "sonar.coverage.jacoco.xmlReportPaths", "${project.projectDir}/build/reports/testStagingDebugUnitTestCoverage/*"
        property "sonar.groovy.jacoco.reportPath", "${project.projectDir}/build/reports/testStagingDebugUnitTestCoverage/*"
        property "sonar.coverage.exclusions", "${coverageExclusions.join(', ')}"

    }
}

We try to make “sonar.junit.reportPaths” as next paths but non of them worked.

  • property "sonar.junit.reportPaths", "**/test-results/**/*.xml"
  • property "sonar.junit.reportPaths", "${project.projectDir}/build/test-results/testStagingDebugUnitTest/"
  • property "sonar.junit.reportPaths", "${project.projectDir}/build/test-results/testStagingDebugUnitTest/*.xml"
  • property "sonar.junit.reportPaths", "${project.projectDir}/build/test-results/testStagingDebugUnitTest/fullPathForOneTestResultFile.xml"

I sure now the issue only happens with Kotlin classes, I add Java class and UnitTest for this class then the SonarQube was able to update Unit Tests success but only for the Jave test.

We ask for your help to fix this issue
So what do I need to do to make sure SonarQube read the Kotlin UnitTest?

I see the same problem in the previous closed topic
[Kotlin Unit Test result not showing on SonarQube 8.5 developer] (Kotlin Unit Test result not showing on SonarQube 8.5 developer)

Have you already tried lowering you Sonarqube version (8.6 for instance) just to be sure it’s not something not yet implemented in latest sonarqube version? It happened to me in that thread you mentioned.

Ok, I’ll check that

I try with v8.6
I still do not have UnitTest appear for Kotlin classes

I was trying all the next paths
We try to make “sonar.junit.reportPaths” as next paths but non of them worked.
We try to make “sonar.junit.reportPaths” as next paths but non of them worked.

  • property "sonar.junit.reportPaths", "**/test-results/**/*.xml"
  • property "sonar.junit.reportPaths", "${project.projectDir}/build/test-results/testStagingDebugUnitTest/"
  • property "sonar.junit.reportPaths", "${project.projectDir}/build/test-results/testStagingDebugUnitTest/*.xml"
  • property "sonar.junit.reportPaths", "${project.projectDir}/build/test-results/testStagingDebugUnitTest/fullPathForOneTestResultFile.xml"

I sure now the issue only happen with Kotlin classes, I add Java class and UnitTest for this class then the SonarQube was able to update Unit Tests success but only for Jave test.

So what I need to do to make sure SonarQube read the Kotlin UnitTest?

Hi @marcoc, Kindly could you tell me what change need to take, so SonarQube can read the Kotlin UnitTest class

I’m sorry but I’m not a sonarqube expert. :slight_smile:

My problem was with Sonarqube version which hadn’t implemented yet support for Kotlin unit test. I don’t know about version 9.0.1
Maybe some more skilled than me with Sonar can help

Thank you for your reply

Hello Ahmed,

Have you been able to find a solution to your problem in the meantime? Generally, the display of the number of unit tests in SonarQube is supported. You can see an example of this here. Is this the kind of data you are looking for?

Hello @jbeleites

Could you please share the repo details for this, so that we can verify what is missing

Thanks

Of course, the repository I provided as an example above is the Kotlin analyzer, as found in all Sonar products.