Sonar Jacoco to install Kotlin does not generate code coverage

I am trying to do Sonar Setup with Jacoco for Kotlin to generate a Code Coverage report, but it does not show any code coverage. Checking the Sonar Console, it shows the following error. Before anyone came across this question, any suggestion on what to skip.

Meta info

plugin using sonarqube version "2.6.1"

gradleVersion = '3.0.1'

kotlinVersion = '1.2.21'

Sonarqube Version = Version 6.7.1 (Build 35068) - LGPL v3

Disappointing the part, my installation project creates a clean code coverage report :(. PFA.

enter image description here

Edit: find the project structure.

I am adding a sonar & Jacoco gradle file setting that I use to generate a sonar matrix report.

enter image description here

Here is the sonar.gradle file:

sonarqube { properties { property "sonar.projectKey", "jacoco.sonar.test" property "sonar.projectName", "Sonar Jacoco Test" property "sonar.projectVersion", "1.1" property "sonar.java.source", "7" property "sonar.android.lint.report", "build/outputs/lint-results.xml" property "sonar.java.binaries", "build/tmp/kotlin-classes" property "sonar.java.test.binaries", "build/intermediates/classes/test/,build/tmp/kotlin-classes/devDebugUnitTest" property "sonar.tests","src/test/java" property "sonar.sources","src/main/java" property "sonar.java.coveragePlugin", "jacoco" property "sonar.jacoco.reportPaths","build/jacoco/testDevDebugUnitTest.exec" property "sonar.junit.reportsPath","build/test-results/testDevDebugUnitTest" } } 

and here is the jacoco.gradle file

 apply plugin: 'jacoco' jacoco { toolVersion = "0.7.9" reportsDir = file("${project.projectDir}/app/build/reports") } task jacocoTestReport(type: JacocoReport, dependsOn: "app:testDevDebugUnitTest") { group = "Reporting" reports { xml.enabled = true html.enabled = true } def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/*$ViewInjector*.*', '**/*$ViewBinder*.*', '**/*$MembersInjector*.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*'] classDirectories = fileTree( dir: "${project.projectDir}/app/build/intermediates/classes/dev", excludes: fileFilter ) + fileTree( dir: "${project.projectDir}/app/build/tmp/kotlin-classes/devDebug", excludes: fileFilter ) // sources sourceDirectories = files(["${project.projectDir}/app/src/main/java"]) executionData = files("${project.projectDir}/app/build/jacoco/testDevDebugUnitTest.exec") } 

After the gradient commands, I use Jacobo to generate the report, and then to report the fall.

 ./gradlew clean jacocoTestReport sonarqube 

I noticed that after I receive, there must be some way.

Coverage information has not been collected. Did you forget to include debugging information in compiled classes?

Sorry if this looks a bit; but this is the best I have found to take stock in one place. Also note that I tried a similar setup with a Java class instead of kotlin, creating a report with code coverage.

+9
android sonarqube jacoco sonarqube-ops
source share
2 answers

If you use orchestras to test Android, this is most likely a problem.

I had the same problem today, and after disconnecting the android orchestra, the cover works again.

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

I'm not sure how Kotlin Android assemblies are configured, but in my Android Java build.gradle I had to comment on a test orchestra like this:

 android { ... testOptions { // temporarily disable the orchestrator as this breaks coverage: https://issuetracker.google.com/issues/72758547 //execution 'ANDROID_TEST_ORCHESTRATOR' ... } } 
0
source share

Hi. You still have a solution. I read that for jacoco and kotlin you can only use jacoco xml report, not jacoco.exec files. They only work with java files.

I am testing it now.

Regards, Marcel

0
source share

All Articles