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

Add an example how to limit coverage to a specific custom test source set / test suite #54

Closed
sschuberth opened this issue Nov 11, 2021 · 4 comments

Comments

@sschuberth
Copy link

Many projects have custom tests and belonging source sets defined, like integTests (integration tests) or funTests (functional tests).

Please provide an example on how to limit determining coverage / running tests to only those tests from a specific source set / test suite.

@shanshin
Copy link
Collaborator

Hi,
at the moment, there is no stable way to limit the set of classes used for verification (source sets, directories, etc.).

The design of the API for verification is currently in progress (#19), so it would be helpful if you described the complex use cases of verification for your application.

@sschuberth sschuberth changed the title Add an example how to limit coverage to a specific custom test sourtce set / test suite Add an example how to limit coverage to a specific custom test source set / test suite Nov 11, 2021
@ghost
Copy link

ghost commented Nov 25, 2021

I want exactly the same as this basically - my project has the following tasks alongside the default test one, for a mixture of convenience and speed (in CI, the unitTest and integrationAndE2E tasks get run in parallel by different runners):

task unitTest(type: Test) {
    useJUnitPlatform {
        excludeTags "integration", "e2e"
    }
}

task updateScreenshots(type: Test) {
    jvmArgs '-DupdateSnapshots=true'
    useJUnitPlatform {
        includeTags "screenshot"
    }
}

task integrationAndE2E(type: Test) {
    useJUnitPlatform {
        includeTags "integration", "e2e"
    }
}

Currently, though, this means that running koverReport will run my whole test suite twice as it kicks off all the test tasks! Would be great to have a way to tell it to only run a specified test task. This could be done either way around, e.g:

./gradlew koverReport --tasks unitTest

or

./gradlew unitTest --generateKoverReport

@ghost
Copy link

ghost commented Nov 25, 2021

I tried this, which works but seems to make these tasks get skipped always (not just when running koverReport):

tasks.koverReport {
    updateScreenshots.onlyIf { false }
    integrationAndE2E.onlyIf { false }
    unitTest.onlyIf { false }
}

For now I can use -x in my build pipeline to say ./gradlew koverReport -x unitTest -x ..., which gets me basically where I want to be.

@shanshin
Copy link
Collaborator

shanshin commented Apr 8, 2022

Duplicates #19

@shanshin shanshin closed this as completed Apr 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants