This is a JUnit extension that shards the tests for parallel execution.
It selects tests by hashing the test class and method name.
Tests are sharded if these environment variables are present:
KOCHIKU_WORKER_CHUNK=1
KOCHIKU_TOTAL_WORKERS=3
The set of tests is divided into a range with KOCHIKU_TOTAL_WORKERS
parts, and runs only the
tests in the part KOCHIKU_WORKER_CHUNK
. The KOCHIKU_WORKER_CHUNK
environment variable is a
1-based index, so if there are 3 workers the chunks should be 1, 2, and 3.
To use this in Gradle, enable autodetection in the test {}
section of your build.gradle
:
test {
systemProperty 'junit.jupiter.extensions.autodetection.enabled', 'true' // For test sharding.
...
}
You'll also need to add this module to your test's runtime classpath:
dependencies {
testRuntimeOnly dep.testSharding
}
Some related work on JUnit itself:
junit-team/junit5#1041
junit-team/junit5#1055