|
| 1 | +# Split Tests Java |
| 2 | + |
| 3 | +Divides a test suite into groups with equal execution time, based on prior test timings. |
| 4 | + |
| 5 | +This ensures optimal parallel execution. Since test file runtimes can vary significantly, splitting them evenly without |
| 6 | +considering timing may result in inefficient grouping. |
| 7 | + |
| 8 | +## Compatibility |
| 9 | + |
| 10 | +This tool was written for Java and released as JAR archive. |
| 11 | + |
| 12 | +## Usage |
| 13 | + |
| 14 | +Download and extract the latest build from the releases page. |
| 15 | + |
| 16 | +### Using the command line |
| 17 | + |
| 18 | +Execute the test split with the required arguments. |
| 19 | +The tool returns the set of test classes for the current split, joined by spaces. |
| 20 | + |
| 21 | +```shell |
| 22 | +java -jar split-tests-java.jar --split-index 0 --split-total 10 --glob '**/*Test.java' |
| 23 | +``` |
| 24 | + |
| 25 | +### Using a JUnit report |
| 26 | + |
| 27 | +For example, check out the project into `project` and the JUnit reports into `reports`. |
| 28 | + |
| 29 | +``` |
| 30 | +java -jar split-tests-java.jar --split-index 0 --split-total 10 --glob 'project/**/*Test.java' --junit 'reports/**/*.xml' |
| 31 | +``` |
| 32 | + |
| 33 | +## Arguments |
| 34 | + |
| 35 | +```plain |
| 36 | +Usage: <main class> [options] |
| 37 | + Options: |
| 38 | + --debug, -d |
| 39 | + Enables debug logging. |
| 40 | + Default: false |
| 41 | + --exclude-glob, -e |
| 42 | + Glob pattern to exclude test files. Defaults to '**/*Abstract*'. Make |
| 43 | + sure to single-quote the pattern to avoid shell expansion. |
| 44 | + * --glob, -g |
| 45 | + Glob pattern to find test files. Make sure to single-quote the pattern |
| 46 | + to avoid shell expansion. |
| 47 | + --help, -h |
| 48 | + Prints the usage. |
| 49 | + --junit-glob, -j |
| 50 | + Glob pattern to find JUnit reports. Make sure to single-quote the |
| 51 | + pattern to avoid shell expansion. |
| 52 | + * --split-index, -i |
| 53 | + This test split index. |
| 54 | + Default: 0 |
| 55 | + * --split-total, -t |
| 56 | + Total number of test splits. |
| 57 | + Default: 0 |
| 58 | + --working-directory, -w |
| 59 | + The working directory. Defaults to the current directory. |
| 60 | +``` |
| 61 | + |
| 62 | +## Compilation |
| 63 | + |
| 64 | +This tool is written in Java and uses Gradle as build tool. |
| 65 | + |
| 66 | +- Install Java 21 |
| 67 | +- Checkout the repository |
| 68 | +- `./gradlew shadowJar` |
0 commit comments