Kotlin / kotlinx-kover

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Kover not executing test in non android modules.

martin-petrulak-db opened this issue · comments

Hello there:)
First of all, thank you for a great tool !
We would like to use Kover in our Android codebase which consists of hundreds of modules. This modules are:

  1. JVM module (kotlin("jvm"))
  2. Android module (id("com.android.library"))
  3. Flavorized android modules (BrandADebug, BrandBRelease etc..)

We are using version 0.7.3 because 0.7.4 fails with

Execution failed for task ':app:koverHtmlReportBrandADebug'.
> Null byte present in file/path name. There are no known legitimate use cases for such data, but several injection attacks may use it

Tool, works fine and generates reports for Android modules, however the tests in pure JVM modules are not triggered, therefor reports are not generated.

We run the following command: ./gradlew koverHtmlReportBrandADebug

I had a look at examples, but did not find an example where jvm and android modules are mixed.

Do you maybe know what we are missing?

Here is the config which resides in the main app module

koverReport {
    // filters for all report types of all build variants
    filters {
        includes{
            packages("com.our.package")
        }

        excludes {
            packages("*.view")
            classes(
                "*Fragment",
                "*Fragment\$*",
                "*Activity",
                "*Activity\$*",
                "*ModelFactory",
                "*_Factory*",
                "*.databinding.*",
                "*.BuildConfig"
            )
        }
    }
}

dependencies {

    project
        .rootProject
        .also {   println("KOVER ADDING STUFF") }
        .subprojects
        .filter {
           file("${it.projectDir}/build.gradle.kts").exists() // exclude directories which only nest modules
        }
        .forEach {
            println("KOVER adding:${it.projectDir}")
            kover(project(it.path))
        }

    implementation("DEPENDENCIES_BELOW")
}

Hi,
when the generation of a specific variant of the report is started, tests are run only for the corresponding version of the Android build variant (e.g.brandADebug).
Since JVM modules do not have any build variants, it is necessary to manually explicitly specify which tests should be run together.

To do this, in the 0.7.x version, you can combine Android build variants with JVM tests, thus:

koverReport {
    defaults {
        mergeWith("brandADebug")
    }
}

This will allow to generate a report for JVM modules and for building variant brandADebug of Android modules using the koverHtmlReport command.

See docs.

@shanshin thank you this works. Was actually trying this in 0.7.4 most of the time where its not working.
Thank you for your support!