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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

commonTest should be skipped #245

Closed
mustafaozhan opened this issue Sep 30, 2022 · 9 comments 路 Fixed by #295
Closed

commonTest should be skipped #245

mustafaozhan opened this issue Sep 30, 2022 · 9 comments 路 Fixed by #295
Assignees
Labels
Bug Bug issue type Kover Gradle Plugin S: in progress Status: implementing or design in process
Milestone

Comments

@mustafaozhan
Copy link

Hello 馃憢

Currently kover calculates the coverages for the test classes in commonTest in Kotlin Multiplatform projects. It should skip the test folders. If it is not possible we should have option to exclude files by directory currently only package option is available.

In Android module test folder is already skipped, we should have the same behavior for KMP projects for commonTest folder. It causes unfair coverage increase.

@shanshin
Copy link
Collaborator

shanshin commented Oct 4, 2022

Hi,
may you clarify, do you want the Kover report not to take into account the coverage of tests that are located in commonTest?

@mustafaozhan
Copy link
Author

@shanshin yeap exactly, it is done automatically for android apps/libraries for test folder, but the equivalent folder is called commonTest in multiplatform libraries, so we should not take them in account when we calculate the overall coverage.

Note: Even though it can be super edge case, there are also jvmTest iosTest jsTest... folders in Multiplatform libraries, depends on which platforms you enable, so preferably the solution should include every possible test folders.

@shanshin
Copy link
Collaborator

shanshin commented Oct 4, 2022

At the moment, there is no way to disable the use of tests from a specific source set.
As a workaround, you may arrange all tests from the commonTest in an individual package and exclude its contents from instrumentation.

@shanshin shanshin added Kover Gradle Plugin Feature Feature request issue type labels Oct 4, 2022
@shanshin
Copy link
Collaborator

shanshin commented Oct 4, 2022

@mustafaozhan, I would also like to clarify, the classes from commonTest were included in the HTML report?

@mustafaozhan
Copy link
Author

Hello @shanshin thank you for your answers!

As a workaround, you may arrange all tests from the commonTest in an individual package and exclude its contents from instrumentation.

Unfortunately, this will require different setup for each module maybe we need a more general workaround, I tried adding below code into root build.gradle but it didn't work, do you have any suggestion ?

koverMerged {
    enable()
    filters {
        classes {
            excludes += listOf(
                "*Test",
                "*.*Test",
                "*.*.*Test",
                "*.*.*.*Test",
                "*.*.*.*.*Test"
            )
        }
    }
}

@mustafaozhan, I would also like to clarify, the classes from commonTest were included in the HTML report?

Yes I can see these classes both in xml and html reports.

@shanshin shanshin added Bug Bug issue type and removed Feature Feature request issue type labels Oct 5, 2022
@shanshin
Copy link
Collaborator

shanshin commented Oct 5, 2022

This is definitely a bug, classes from test source sets should not get into the report.

@mustafaozhan
Copy link
Author

mustafaozhan commented Oct 5, 2022

@shanshin Thank you for your answer, I agree with you, test sources should be excluded

Also, I think the workaround I have posted should work too, I will create a separate issue for that.

Created issue: #252

@hoc081098
Copy link

hoc081098 commented Oct 13, 2022

I have the same issue. excludes does not work (#252)

android {
 testOptions {
    unitTests {
      isReturnDefaultValues = true
      all {
        if (it.name == "testDebugUnitTest") {
          it.extensions.configure<kotlinx.kover.api.KoverTaskExtension>() {
            isDisabled.set(false)
            excludes.addAll(
              "hilt_aggregated_deps.*",
              "io.mockative.*"
            )
          }
        }
      }
    }
  }
}

@shanshin shanshin added the S: in progress Status: implementing or design in process label Oct 27, 2022
@shanshin shanshin self-assigned this Oct 27, 2022
@shanshin shanshin added this to the Release 0.7.0 milestone Oct 27, 2022
@shanshin
Copy link
Collaborator

Fixed in 0.7.0-Alpha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Bug issue type Kover Gradle Plugin S: in progress Status: implementing or design in process
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants