How can I generate CodeCoverage-Reports with Kover?

878 Views Asked by At

I am trying out Kotlin Native with a tiny project on my system. At a certain point I wanted to get the Code-Coverage of my tests. IntelliJ offers the Option "Run with Coverage" which did not generate coverage reports. After a little search I found kover which can provide CodeCoverage-Reports for Kotlin native.

Unfortunately I am unable make it working even with a minimal setup as the following.

build.gradle.kts

plugins {
    kotlin("multiplatform") version "1.8.0"
    id("org.jetbrains.kotlinx.kover") version "0.6.1"
}

group = "me.user"
version = "1.0-SNAPSHOT"

repositories {
    mavenCentral()
}

kotlin {
    macosX64()
    sourceSets {
        val macosX64Main by getting
        val macosX64Test by getting
    }
}

Main.kt

class Main{
    fun add(first : Int, second : Int) : Int{
        return 4;
    }
}

MainTest.kt

import kotlin.test.Test
import kotlin.test.assertEquals

class MainTest{
    @Test
    fun addTest(){
        assertEquals(Main().add(2,2), 4);
    }
}

I followed the description here and the documentation. At the documentation it states, that after applying the plugin with

plugins {
     id("org.jetbrains.kotlinx.kover") version "0.6.1"
}

Once you’ve applied Kover, you can run it without additional configuration.

Unfortunately neither running allTests nor running the report-Tasks generates CodeCoverage files.

What am I missing?

1

There are 1 best solutions below

0
david On

It was a known issue which should be fixed in a upcoming release.