Skip to content

Commit afe0894

Browse files
committed
Add integration test
1 parent 25d52b2 commit afe0894

20 files changed

+273
-0
lines changed
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
name: Integration tests
2+
3+
on:
4+
push:
5+
branches: ["**"]
6+
7+
concurrency:
8+
group: integration-test-${{ github.ref }}
9+
cancel-in-progress: true
10+
11+
env:
12+
split-total: 4
13+
14+
jobs:
15+
generate-split-index-json:
16+
name: Generate split indexes
17+
runs-on: ubuntu-latest
18+
outputs:
19+
json: ${{ steps.generate.outputs.split-index-json }}
20+
steps:
21+
- name: Checkout split-tests-java-action
22+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
23+
24+
- name: Generate split index list
25+
id: generate
26+
uses: ./generate-split-index-json
27+
with:
28+
split-total: ${{ env.split-total }}
29+
30+
integration-test:
31+
name: "Test #${{ matrix.split-index }}"
32+
runs-on: ubuntu-latest
33+
needs:
34+
- generate-split-index-json
35+
permissions:
36+
contents: read
37+
checks: write
38+
strategy:
39+
fail-fast: false
40+
matrix:
41+
split-index: ${{ fromjson(needs.generate-split-index-json.outputs.json) }}
42+
env:
43+
DOWNLOAD_JAR: false
44+
JAR_PATH: split-tests-java/build/libs/split-tests-java.jar
45+
steps:
46+
- name: Checkout split-tests-java-action
47+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
48+
49+
- name: Checkout split-tests-java
50+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
51+
with:
52+
repository: Donnerbart/split-tests-java
53+
path: split-tests-java
54+
55+
- name: Set up JDK 21
56+
uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4
57+
with:
58+
distribution: temurin
59+
java-version: 21
60+
61+
- name: Set up Gradle
62+
uses: gradle/actions/setup-gradle@94baf225fe0a508e581a564467443d0e2379123b # v4
63+
64+
- name: Compile split-tests-java
65+
working-directory: split-tests-java
66+
run: ./gradlew shadowJar
67+
68+
- name: Split tests
69+
id: split-tests
70+
uses: ./
71+
with:
72+
split-index: ${{ matrix.split-index }}
73+
split-total: ${{ env.split-total }}
74+
glob: '**/integration-test/tests/*Test.java'
75+
exclude-glob: '**/NoClassNameTest.java'
76+
junit-glob: '**/integration-test/reports/*.xml'
77+
format: 'list'
78+
new-test-time: 'average'
79+
calculate-optimal-total-split: true
80+
debug: true
81+
82+
- name: Assert split tests
83+
env:
84+
SPLIT_INDEX: ${{ matrix.split-index }}
85+
ACTUAL: ${{ steps.split-tests.outputs.test-suite }}
86+
run: |
87+
case "$SPLIT_INDEX" in
88+
"0")
89+
EXPECTED="de.donnerbart.example.SlowestTest"
90+
;;
91+
"1")
92+
EXPECTED="NoPackageTest de.donnerbart.example.ThirdPartyLibraryTest"
93+
;;
94+
"2")
95+
EXPECTED="de.donnerbart.example.NoTimingOneTest de.donnerbart.example.WhitespaceClassDefinitionTest"
96+
;;
97+
"3")
98+
EXPECTED="de.donnerbart.example.NoTimingTwoTest de.donnerbart.example.SlowTest de.donnerbart.example.FastTest"
99+
;;
100+
*)
101+
echo "Unexpected split index"
102+
exit 1
103+
;;
104+
esac
105+
echo "Expected: $EXPECTED"
106+
echo "Actual: $ACTUAL"
107+
if [ "$ACTUAL" != "$EXPECTED" ]; then
108+
echo "The split tests are not matching"
109+
exit 1
110+
fi

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
[![Integration tests](https://github.com/Donnerbart/split-tests-java-action/actions/workflows/integration-test.yml/badge.svg)](https://github.com/Donnerbart/split-tests-java-action/actions/workflows/integration-test.yml)
2+
[![Release](https://github.com/Donnerbart/split-tests-java-action/actions/workflows/release.yml/badge.svg)](https://github.com/Donnerbart/split-tests-java-action/actions/workflows/release.yml)
3+
14
# @donnerbart/split-tests-java-action
25

36
Divides a test suite into groups with equal execution time, based on prior test timings.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<testsuite name="de.donnerbart.example.DeletedTest" tests="1" skipped="0" failures="0" errors="0"
3+
timestamp="2025-01-01T00:00:00" hostname="example" time="2.374">
4+
<properties/>
5+
<testcase name="testDeletedMethod()"
6+
classname="de.donnerbart.example.DeletedTest" time="2.374"/>
7+
<system-out><![CDATA[]]></system-out>
8+
<system-err><![CDATA[]]></system-err>
9+
</testsuite>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<testsuite name="de.donnerbart.example.FastTest" tests="1" skipped="0" failures="0" errors="0"
3+
timestamp="2025-01-01T00:00:00" hostname="example" time="2.374">
4+
<properties/>
5+
<testcase name="testFastMethod()"
6+
classname="de.donnerbart.example.FastTest" time="2.374"/>
7+
<system-out><![CDATA[]]></system-out>
8+
<system-err><![CDATA[]]></system-err>
9+
</testsuite>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<testsuite name="de.donnerbart.example.SlowTest" tests="1" skipped="0" failures="0" errors="0"
3+
timestamp="2025-01-01T00:00:00" hostname="example" time="12.386">
4+
<properties/>
5+
<testcase name="testFastMethod()"
6+
classname="de.donnerbart.example.SlowTest" time="12.386"/>
7+
<system-out><![CDATA[]]></system-out>
8+
<system-err><![CDATA[]]></system-err>
9+
</testsuite>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<testsuite name="de.donnerbart.example.SlowestTest" tests="1" skipped="0" failures="0" errors="0"
3+
timestamp="2025-01-01T00:00:00" hostname="example" time="153.457">
4+
<properties/>
5+
<testcase name="testFastMethod()"
6+
classname="de.donnerbart.example.SlowestTest" time="153.457"/>
7+
<system-out><![CDATA[]]></system-out>
8+
<system-err><![CDATA[]]></system-err>
9+
</testsuite>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package de.donnerbart.example;
2+
3+
abstract class AbstractTest {
4+
5+
abstract void implementableMethod();
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package de.donnerbart.example;
2+
3+
abstract class BaseTest {
4+
5+
abstract void implementableMethod();
6+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package de.donnerbart.example;
2+
3+
import org.junit.jupiter.api.Disabled;
4+
import org.junit.jupiter.api.Test;
5+
6+
@Disabled("This test should be skipped")
7+
class DisabledTest {
8+
9+
@Test
10+
void testDisabled() {
11+
}
12+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package de.donnerbart.example;
2+
3+
import org.junit.jupiter.api.Test;
4+
5+
class FastTest {
6+
7+
@Test
8+
void testFastMethod() {
9+
}
10+
}

0 commit comments

Comments
 (0)