Code coverage always in 0.0%

I am trying to use sonarqube (version 8:latest - docker)with jacoco and detekt. However, coverage does not exceed 0.0%
my build.gradle.kts

val kafkaVersion: String = "2.4.1"
val kotlinVersion = "0.20.0"
val jacksonKotlinVersion = "2.10.3"
val kotlinCoroutineVersion = "1.3.5"
val ariesTestVersion = "0.0.1"
val jacocoVersion = "0.8.5"

plugins {
    kotlin("jvm") version "1.3.70"
    id("org.sonarqube") version "2.8"
    id("io.gitlab.arturbosch.detekt") version "1.9.1"
    jacoco
    `maven-publish`
}


repositories {
    mavenLocal()
    jcenter()
    maven {
        url = uri("http://packages.confluent.io/maven/")
    }
}


group = "com.rjdesenvolvimento.aries.commons.kafka"
version = "0.0.1"


dependencies {
    implementation(platform("org.jetbrains.kotlin:kotlin-bom"))
    implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
    implementation("org.apache.kafka:connect-json:$kafkaVersion")
    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinCoroutineVersion")
    implementation("com.fasterxml.jackson.module:jackson-module-kotlin:$jacksonKotlinVersion")
    implementation("io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.9.1")

    testImplementation("com.rjdesenvolvimento.aries.commons.test:aries.commons.test:$ariesTestVersion")

    api("org.apache.kafka:kafka-clients:$kafkaVersion")
}

sonarqube {
    properties {
        property("sonar.login", "admin")
        property("sonar.password", "admin")
        property("sonar.host.url", "http://localhost:9000")
        property("sonar.sourceEncoding", "UTF-8")
        property("sonar.projectName", "Commons.Kafka")
        property("sonar.projectKey", "Aries.kt")
        property("sonar.projectVersion", "0.0.1")
        property("sonar.verbose", "true")
        property("sonar.sources", "src/main")
        property("sonar.issuesReport.html.enable", "true")
        property("sonar.issuesReport.console.enable", "true")
        property("sonar.core.codeCoveragePlugin", "jacoco")
        property("sonar.coverage.jacoco.xmlReportPaths", "build/reports/jacoco/jacocoTestReport.xml")
        property("detekt.sonar.kotlin.config.path", "src/main/resources/detekt-config.yml")
    }
}

jacoco {
    toolVersion = jacocoVersion
    reportsDir = file("$buildDir/reports")
}

detekt {
    toolVersion = "1.9.1"
    input = files("src/main/kotlin")
    parallel = false
    config = files("src/main/resources/detekt-config.yml")
    buildUponDefaultConfig = false
    baseline = file("build/baseline/")
    disableDefaultRuleSets = false
    debug = true
    ignoreFailures = false
    reports {
        xml {
            enabled = true
            destination = file("build/reports/detekt.xml")
        }
    }
}

publishing {
    publications {
        create<MavenPublication>("mavenJava") {
            from(components["java"])
        }
    }
}

tasks {
    test {
        useJUnitPlatform()
        testLogging {
            events("passed", "skipped", "failed")
        }
        finalizedBy(jacocoTestReport)
    }
    jacocoTestReport {
        reports {
            xml.isEnabled = true
            csv.isEnabled = false
            html.isEnabled = true
            html.destination = File("$buildDir/reports/jacoco")
        }
    }
    compileKotlin {
        kotlinOptions.jvmTarget = "11"
    }
    compileTestKotlin {
        kotlinOptions.jvmTarget = "11"
    }
}

Could it be the same issue discussed here: sonar.coverage.jacoco.xmlReportPaths not reporting coverage?

1 Like

Thanks Duarte. =).
Solved my problem.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.