How can I make the "test" task run a given test that exists in only one subproject, without failing in all others?

I am trying to set up a jenkins job where users can requests various tests to be run, based only on the class name (which they know from the test reports provided by earlier runs). The “obvious” solution fails

$ gradlew test --tests ContentQueryPredicateTest
FAILURE: Build failed with an exception.
  * What went wrong:
Execution failed for task ':Documentation:test'.
> No tests found for given includes: [ContentQueryPredicateTest]

This fails because gradle tries to run the specified test in every project, instead of only in the project(s) that actually have such a test. Ths, to make it work, I have to specify the project (gradlew :MainProject:SubProject:test --test ContentQueryPredicateTest). But this requires that the user knows the project structure, which he does not.

Is there a good solution to run “a named test” in “any project”, without failing in the other projects?


I’m not aware of one.