I have a java project with a lot of tests. My build is using Gradle and tests are using TestNG and invoked by gradle. I would like to speed up testing a build by running my build simultaneously on multiple workers and having each worker run only a subset of the tests.
Each node will provide 2 environment variables
TOTAL_NODES is the number of nodes running my build and
NODE_NUMBER is the number assigned to this particular node.
I want a way of partitioning the tests so that each node runs ~ 1/TOTAL_NODES tests and each test is run exactly once. Is there a simple way of doing this with gradle and TestNG?
I could manually divide tests into even groups by labeling each one in a specific group, but there are many tests and that's a major maintenance hassle, plus it doesn't scale if the number of nodes change.
Gradle offers tests filtering, but it seems like it's all based on class name matching, and can't accept arbitrary filtering functions. I could find all the test files and then subdivide them according to some hashing scheme before plugging them into a test filter, but it seems needlessly complex.
Is there a simpler way of doing this?