Looking for similar behaviour to forkEvery but running specific *groups* of test classes in the same process

Hello,

I have a set of JUnit test classes, like

ATest
BTest
CTest

I’d like to be able to programmatically let Gradle know I’d like to run certain groups of tests in their own JVM forks. E.g. I’d like gradle to know I want it to run

Fork 1:
ATest
BTest

Fork 2:
CTest

I’d like to be able to let gradle know programmatically which tests belong in which forks (rather than pre-hardcoding a list). This programmatic discovery ideally would be inside some Java code in the tests section of my project that gradle could somehow call.

Is anything like this possible?

Thanks very much in advance!