Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate Kover report for Integration tests #732

Open
tembi4 opened this issue Feb 5, 2025 · 2 comments
Open

Separate Kover report for Integration tests #732

tembi4 opened this issue Feb 5, 2025 · 2 comments
Assignees
Labels
Question Support request issue type S: waiting for clarification Status: additional information required to proceed

Comments

@tembi4
Copy link

tembi4 commented Feb 5, 2025

We're migrating from Java to Kotlin and from JaCoCo to Kover. The structure of source folders:
my_project:

  • src
  • unitTestSrc
  • integrationTestSrc

I use test to run unit tests and integrationTest task to execution only tests from integrationTestSrc.

How can I create a separate tasks for unit test coverage and integration? I need to run the integration tests in pipeline only after the unit test coverage verification is passed.
Currently (I just simply added the Kover), when I run koverHtmlReport it runs integrationTest (probably because it's of type Test?) and unit tests and somehow merge results where:

  • source is covered
  • but I also have my integration test (with default/empty package) inside this report as well.

So, I need, basically, run unit tests, generate/verify , after this run integration test and generateReport/verifyRules only for what is covered by Int tests.
Thanks in advance!

@tembi4 tembi4 added Question Support request issue type S: untriaged Status: issue reported but unprocessed labels Feb 5, 2025
@shanshin
Copy link
Collaborator

Hi,
could you clarify is your project a single-module and JVM?

Are directories

src
unitTestSrc
integrationTestSrc

placed in different source sets?

If so, you could create additional report variants, each for a specific source set.
E.g.

kover {
    currentProject {
        createVariant("unit") {
            sources.includedSourceSets.add("unitTest")
        }

        createVariant("integration") {
            sources.includedSourceSets.add("integrationTest")
        }
    }
}

Thus, the koverVerifyUnit and koverVerifyIntegration tasks will be created, which will check the coverage in the unitTest and integrationTest source sets, respectively.

@shanshin shanshin added S: waiting for clarification Status: additional information required to proceed and removed S: untriaged Status: issue reported but unprocessed labels Feb 10, 2025
@rlewan
Copy link

rlewan commented Feb 19, 2025

Hello 🙋‍♂️

I believe I need the same thing as @tembi4, let me phrase it in my words.

My source sets are:

  • main
  • test (unit tests)
  • integration (integration tests)

I'd like to be able to run the following tasks and receive their corresponding outputs:

  1. koverHtmlReport: generates a report that shows the coverage of sources in main as covered by tests from test and integration
  2. koverHtmlReportUnit: generates a report that shows the coverage of sources in main as covered by tests from test
  3. koverHtmlReportIntegration: generates a report that shows the coverage of sources in main as covered by tests from integration

@shanshin I don't think your suggestion works for me as what it does is to denote the sources that should have their coverage verified. What I need is to include or exclude tests that are used to generate coverage information.

I thought I could achieve this by using variants and instrumentation. The following configuration sample works for the total variant:

kover {
    useJacoco()

    currentProject {
        sources {
            includedSourceSets.addAll("main")
        }

        instrumentation {
            disabledForTestTasks.add("integration")
        }
    }
}

I've tried the following, but configuring instrumentation per variant isn't possible:

kover {
    useJacoco()

    currentProject {
        sources {
            includedSourceSets.addAll("main")
        }

        createVariant("unit") {
            instrumentation { // 'fun instrumentation(block: Action<KoverProjectInstrumentation>): Unit' can't be called in this context by implicit receiver. Use the explicit one if necessary
                disabledForTestTasks.add("integration")
            }
        }
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question Support request issue type S: waiting for clarification Status: additional information required to proceed
Projects
None yet
Development

No branches or pull requests

3 participants