Kotlin / kotlinx-kover

Apache License 2.0
1.25k stars 46 forks source link

Configuring Kover for unit tests shards on CI #585

Open trupin opened 1 month ago

trupin commented 1 month ago

Hi Kover Team!

I have a CI which runs unit tests on multiple shards. I want to configure Kover to make it run a subset of projects. So, say my shards are configured this way

shard1:
- projectA
- projectB

shard2:
- projectC
- projectD

I want to configure Kover in such a way so that when I select to run the tests in shard1, it runs the tests of projectA and projectB and generates a coverage report.

So my first question is, what is the recommended way to configure that?

My second question is about the merge feature of Kover. Say I run Kover for shard1, it will run the tests of projectA and projectB. Now, projectA has tests that hit some code located in projectC (in shard2). Will Kover be able to merge that coverage and show it in the report?

The reason I'm asking is because I haven't been able to find the right configuration to test it yet, but it would help me to know whether that is supported out of the box.

Thanks in advance for your help!

shanshin commented 1 month ago

Hi, could you please clarify, this is how you are setting up the merge report now, for example, for only projectA and projectB projects. Are you using convention plugin or subprojects { ... } block?

shanshin commented 1 month ago

About second question: you may create binary report with koverBinaryReport task and from the these reports, you can generate a readable report (HTML or XML) by Kover CLI.

I think we can add a special task class, with which users can create own report generation tasks, like

tasks.create<KoverCustomHtmlReport>("myHtml") {
  inputReports.addAll(file("report-from-shard1.ic"), file("report-from-shard2.ic"))

  htmlDir = layout.buildDirectory.dir("my-html")
}

See #588