Kotlin/kotlinx-kover

How to generate a merge report?

Closed this issue · 6 comments

I have an Android project with several modules but I'm facing an issue, when I execute kover all modules that include generate the report (that's ok) but I want to know if there is a way to generate a merged report of all my modules

this is my current kover config (it is in the root build.gradle.kts)

tasks.register("koverXmlReportDebug") {
    // Configure the report file
    kover {
        currentProject {
            createVariant("custom") {
                add("debug")
            }
        }
        reports {
            filters {
                includes {
                    packages("...")
                    projects = listOf(...)
                }
                excludes {
                    androidGeneratedClasses()
                    // exclusion rules - classes to exclude from report
                   ...
                }
            }
        }
    }
}

I found part of the issue, if i execute koverXmlReportDebug generates each report per module but not a general module, but if I execute koverXmlReport it does execute the general report but it executes all debug and release tasks but I need just one of them (debug or release) which config can I apply to generate a report but executing just one type of task debug or release, either way it will take double of the time

Hi,
generating merged reports for Android projects requires additional configuration, have you reffered the documentation in the relevant section?

Yes I do, this is my current configuration and still not working:

in the root build gradle:

plugins {
    alias(libs.plugins.kover)
}

dependencies {
    kover(projects.moduleA)
    kover(projects.moduleB)
    kover(projects.moduleC)
    kover(projects.moduleDl)
}

kover {
    reports {
        filters {
            includes {
                packages("com.myapp")
            }
            excludes {
                androidGeneratedClasses()
                // exclusion rules - classes to exclude from report
                packages(
                   ...
                )
                files(
                  ...
                )
                annotatedBy(
                   ...
                )
                classes(
                   ...
                )
            }
        }
    }
}

And in each module I have applied the alias(libs.plugins.kover)

Do I need another special configuration to generate the merged report?

Just to clarify, koverXmlReport works but executes both release and debug unit tests and tasks, which takes the double of time, but I if run koverXmlReportDebug the general report is not generated, only a report per module

Pay attention to the section Create custom Report Variants.
You should add

kover {
    currentProject {
        createVariant("custom") {
            add("debug", optional = true)
        }
    }
}

in each module where Kover plugin is applied (including root project).

After that, the :koverXmlReportCustom task must be completed to generate the report.
Important! It is mandatory to specify a colon at the beginning (running task in root project). if the koverXmlReportCustom task is running, it generates individual reports on modules

It worked with the createVariant configuration, thanks!