Skip to content

Commit 68517f0

Browse files
committed
Initial commit
0 parents  commit 68517f0

34 files changed

+1783
-0
lines changed

.editorconfig

Lines changed: 405 additions & 0 deletions
Large diffs are not rendered by default.

.github/workflows/check.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: CI Check
2+
3+
on:
4+
push:
5+
branches: ["**"]
6+
7+
concurrency:
8+
group: unit-test-${{ github.ref }}
9+
cancel-in-progress: true
10+
11+
jobs:
12+
unit-test:
13+
runs-on: ubuntu-latest
14+
timeout-minutes: 5
15+
steps:
16+
- name: Checkout Split Tests Java
17+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
18+
19+
- name: Set up JDK 21
20+
uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4
21+
with:
22+
distribution: temurin
23+
java-version: 21
24+
25+
- name: Setup Gradle
26+
uses: gradle/actions/setup-gradle@0bdd871935719febd78681f197cd39af5b6e16a6 # v4
27+
28+
- name: Gradle check
29+
run: ./gradlew check
30+
31+
- name: Publish test report
32+
uses: mikepenz/action-junit-report@ee6b445351cd81e2f73a16a0e52d598aeac2197f # v5
33+
if: always()
34+
with:
35+
annotate_only: true
36+
detailed_summary: true
37+
job_name: unit-test-report
38+
report_paths: '**/build/test-results/test/TEST-*.xml'

.github/workflows/release.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Release
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
release:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
13+
14+
- name: Setup Java
15+
uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4
16+
with:
17+
distribution: temurin
18+
java-version: 21
19+
20+
- name: Setup Gradle
21+
uses: gradle/actions/setup-gradle@0bdd871935719febd78681f197cd39af5b6e16a6 # v4
22+
23+
- name: Build JAR
24+
run: ./gradlew shadowJar
25+
26+
- name: Upload Release Asset
27+
uses: actions/upload-release-asset@e8f9f06c4b078e705bd2ea027f0926603fc9b4d5 # v1
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
with:
31+
upload_url: ${{ github.event.release.upload_url }}
32+
asset_path: ./build/libs/split-tests-java.jar
33+
asset_name: split-tests-java-${{ github.event.release.name }}.jar
34+
asset_content_type: application/java-archive

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Gradle
2+
.gradle
3+
build/
4+
5+
# IntelliJ
6+
out/
7+
*.iml
8+
.idea/
9+
10+
.java-version
11+
.DS_Store

README.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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`
69+
70+
## Note
71+
72+
split-tests-java is inspired by [`split-tests`](https://github.com/mtsmfm/split-test) for Ruby.
73+
74+
In comparison to split-test, split-tests-java works with default JUnit reports.
75+
The output are also fully qualified class names instead of file names.
76+
This makes it compatible with default Java tooling.

build.gradle.kts

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
plugins {
2+
application
3+
java
4+
alias(libs.plugins.shadow)
5+
}
6+
7+
group = "de.donnerbart"
8+
version = "0.1.0"
9+
10+
application {
11+
mainClass = "de.donnerbart.split.TestSplitMain"
12+
}
13+
14+
java {
15+
toolchain {
16+
languageVersion = JavaLanguageVersion.of(21)
17+
}
18+
}
19+
20+
repositories {
21+
mavenCentral()
22+
}
23+
24+
// ********** dependencies **********
25+
26+
dependencies {
27+
compileOnly(libs.jetbrains.annotations)
28+
implementation(libs.jcommander)
29+
implementation(libs.jackson.dataformat.xml)
30+
implementation(libs.logback.classic)
31+
}
32+
33+
// ********** distribution **********
34+
35+
tasks.shadowJar {
36+
mergeServiceFiles()
37+
archiveBaseName = "split-tests-java"
38+
archiveClassifier = ""
39+
archiveVersion = ""
40+
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
41+
manifest {
42+
attributes["Main-Class"] = "de.donnerbart.split.TestSplitMain"
43+
}
44+
}
45+
46+
// ********** tests **********
47+
48+
dependencies {
49+
testCompileOnly(libs.jetbrains.annotations)
50+
51+
testImplementation(libs.junit.jupiter)
52+
testRuntimeOnly(libs.junit.platform.launcher)
53+
54+
testImplementation(libs.assertj)
55+
testImplementation(libs.equalsVerifier)
56+
testImplementation(libs.systemStubs.core)
57+
testImplementation(libs.systemStubs)
58+
}
59+
60+
tasks.test {
61+
useJUnitPlatform()
62+
}

gradle/libs.versions.toml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[versions]
2+
assertj = "3.27.3"
3+
equalsVerifier = "3.17.5"
4+
jackson = "2.18.2"
5+
jcommander = "1.82"
6+
jetbrains-annotations = "26.0.1"
7+
junit = "5.10.0"
8+
logback = "1.5.16"
9+
systemStubs = "2.1.7"
10+
11+
[libraries]
12+
assertj = { module = "org.assertj:assertj-core", version.ref = "assertj" }
13+
equalsVerifier = { module = "nl.jqno.equalsverifier:equalsverifier", version.ref = "equalsVerifier" }
14+
jackson-dataformat-xml = { module = "com.fasterxml.jackson.dataformat:jackson-dataformat-xml", version.ref = "jackson" }
15+
jcommander = { module = "com.beust:jcommander", version.ref = "jcommander" }
16+
jetbrains-annotations = { module = "org.jetbrains:annotations", version.ref = "jetbrains-annotations" }
17+
junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit" }
18+
junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher" }
19+
logback-classic = { module = "ch.qos.logback:logback-classic", version.ref = "logback" }
20+
systemStubs-core = { module = "uk.org.webcompere:system-stubs-core", version.ref = "systemStubs" }
21+
systemStubs = { module = "uk.org.webcompere:system-stubs-jupiter", version.ref = "systemStubs" }
22+
23+
[plugins]
24+
shadow = { id = "com.gradleup.shadow", version = "8.3.5" }

gradle/wrapper/gradle-wrapper.jar

42.6 KB
Binary file not shown.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
6+
zipStoreBase=GRADLE_USER_HOME
7+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)