1

I have multi module project with both Android & Kotlin modules.

To simplify I have the following modules:

  • :data is an Android module. This just has the variants debug and release.
  • :domain is a Kotlin module.

To setup code coverage I applied the Kover plugin to all modules. I use the latest version (which is 0.9.1 at the time of writing).

Now I could just run an individual task for each module like :data:koverHtmlReportDebug and :domain:koverHtmlReport but I need to create a merged report, otherwise the tests that span multiple modules are not taken into account for the coverage.

So to do this I specified a dependency kover(project(":domain")) in the :data module.

Now if I run :data:koverHtmlReportDebug it doesn't automatically run the coverage for :domain (maybe because it doesn't have the debug variant?). Then if I run :data:koverHtmlReport it does run the coverage for :domain, but it does so for each variant, which takes way longer and is not what I want.

I also tried creating a custom variant so I can specify the correct variant manually, but since domain has no variant, this doesn't work either.

I used this documentation: https://kotlin.github.io/kotlinx-kover/gradle-plugin/#kotlin-multi-module-android-project

And I found a question on GitHub for the same problem. This however was for a way older version and I couldn't get this to work: https://github.com/Kotlin/kotlinx-kover/issues/422

Any suggestions on how to implement Kover correctly for my project?

1 Answer 1

1

I also posted this question on the official GitHub repo. I was on the right track by creating a custom variant. The problem I was having is that :domain has no variants. This is fixed by adding jvm in the :domain module:

kover {
    currentProject {
        createVariant("custom") {
            add("jvm")
        }
    }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.