Test filtering not working as expected

We have a set of tests that we run using a JUnit suite that aggregates many tests. In our build.gradle we select this master test suite using something like:

test {
    filter {
        includeTestsMatching "com.ourcompany.tests.MasterSuite"
    }
}

This all works fine when running the whole test suite.

If we use the --tests command line option to select a subset of tests, e.g. “–tests com.ourcompany.componant.AllTests”, which is a suite of tests for a particular component, the build fails with the error:

* What went wrong:
Execution failed for task ':component:test'.
> No tests found for given includes: [com.ourcompany.tests.MasterSuite](filter.includeTestsMatching) [com.ourcompany.componant.AllTests](--tests filter)

Since the tests included in com.ourcompany.componant.AllTests are a subset of the tests included in com.ourcompany.tests.MasterSuit I was expecting them to be selected and run, but that’s not happening.

Is this a bug with test filtering or with my understanding of the functionality? Any suggestions on how to use the command line to select a subset of the tests specified via the build.gradle file?

Note: this behavior has been verified on Gradle 4.3 and 4.4.

Thanks in advance.

Hi,
Hope you have resolved this issue ?
i am struck in the same problem. Looking in forums and didn’t get workable solution.
Can you please suggest what changes you made to fix this ?

Thanks,
-Suresh