I have multiple source sets that contain separated * unit tests * component tests * integration tests
For regular testing a invocation of gradle test componentTest integrationTest will just execute all of the tests.
For a build pipeline build job individual tests from component tests and integration tests are annotated with a JUnit category annotation @CommitStage. In this situation a gradle invocation gradle componentTest integrationTest now should only select the annotated classes for execution (apply a category filter).
What is the best approach with the least effort. Can I add a JUnit category selector using a system property / gradle property?
Looks like my question was not really clear enough. I have seen that gradle supports JUnit categories out-of-the-box. But my question really should have been if I need to define a new task for each test task that runs in the build-pipeline and needs the JUnit categories filter added.
And then the same for componentTest for which a pipelineComponentTest is implemented.
Is there a simple way that allows to “extend” (inherit) from an existing task definition so I don’t have to repeat the base task definition and don’t duplicate that.