Bad utilisation of gradle executors when including junit test categories

I’m using Gradle 3.1 to run parallel Selenium tests against BrowserStack. I have observed that the Gradle executors seems not to be utilised well. I mean one executor after the another is stopping to work although there are further unexecuted tests in the pipeline.

I have separated my tests by JUnit categories and using Gradle’s includeCategories method to define the JUnit test category I’d like to execute.

Assuming that I would have 100 tests and maxParallelForks set to 5. Gradle creates 5 separate test suites containing 20 tests each w/o taking the desired test category into account. Therefore, the 5 test blocks also contain tests from other categories which should never be executed.

Gradle executors are just working on its own test suite (e.g. 20 tests) and finishing their jobs when its test suite has been processed. As a consequence the utilisation of executors is really bad i.e. some executor might have twice as much tests to be executed than others.

Did you faced similar problems? What workaround did you apply?