Reputation: 2352
I want to run a specific unit test only when I am doing a PR build. During this build I can pass a parameter eg. 'buildType' to specify that it is a PR build.
The test should never run if the buildType isn't explicitly PR build.
How could I achieve such behaviour?
Do I create separate task that I can configure this way somehow. Or do I even create another module?
Upvotes: 1
Views: 177
Reputation: 4841
Actual exclusion will depend on what testing library you are using. For example with JUnit5
you could do this with tags.
You would start by excluding tests tagged with @Tag("PR")
from normal test task. Then you would define specific task such as prTest
that also includes tests tagged with @Tag("PR")
.
test {
useJUnitPlatform {
excludeTags 'PR'
}
}
task prTest(type: Test) {
useJUnitPlatform {
includeTags 'PR'
}
shouldRunAfter test
}
Upvotes: 1