Skip to content

Adapt integration test to new unit test classes #23

Adapt integration test to new unit test classes

Adapt integration test to new unit test classes #23

name: Integration tests
on:
push:
branches: ["**"]
concurrency:
group: integration-test-${{ github.ref }}
cancel-in-progress: true
env:
split-total: 4
jobs:
generate-split-index-json:
name: Generate split indexes
runs-on: ubuntu-latest
outputs:
json: ${{ steps.generate.outputs.split-index-json }}
steps:
- name: Generate split index list
id: generate
uses: donnerbart/split-tests-java-action/generate-split-index-json@25d52b2bdc694f5077fde78908ee84fb23da4d90 # v1
with:
split-total: ${{ env.split-total }}
integration-test:
name: "Test #${{ matrix.split-index }}"
runs-on: ubuntu-latest
needs:
- generate-split-index-json
permissions:
contents: read
checks: write
strategy:
fail-fast: false
matrix:
split-index: ${{ fromjson(needs.generate-split-index-json.outputs.json) }}
env:
DOWNLOAD_JAR: false
JAR_PATH: build/libs/split-tests-java.jar
steps:
- name: Checkout split-test-java
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Set up JDK 21
uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4
with:
distribution: temurin
java-version: 21
- name: Set up Gradle
uses: gradle/actions/setup-gradle@94baf225fe0a508e581a564467443d0e2379123b # v4
- name: Compile split-tests-java
run: ./gradlew shadowJar
- name: Split tests
id: split-tests
uses: donnerbart/split-tests-java-action@25d52b2bdc694f5077fde78908ee84fb23da4d90 # v1
with:
split-index: ${{ matrix.split-index }}
split-total: ${{ env.split-total }}
glob: '**/src/test/resources/tests/*Test.java'
exclude-glob: '**/{NoClassNameTest,UnreadableTest,UnreadableNestedTest}.java'
junit-glob: '**/src/test/resources/reports/*.xml'
format: 'list'
new-test-time: 'average'
calculate-optimal-total-split: true
debug: true
- name: Assert split tests
env:
SPLIT_INDEX: ${{ matrix.split-index }}
ACTUAL: ${{ steps.split-tests.outputs.test-suite }}
run: |
case "$SPLIT_INDEX" in
"0")
EXPECTED="de.donnerbart.example.SlowestTest"
;;
"1")
EXPECTED="NoPackageTest de.donnerbart.example.NoTimingTwoTest de.donnerbart.example.SlowTest"
;;
"2")
EXPECTED="de.donnerbart.example.IgnoreImportTest de.donnerbart.example.ThirdPartyLibraryTest de.donnerbart.example.FastTest"
;;
"3")
EXPECTED="de.donnerbart.example.NoTimingOneTest de.donnerbart.example.WhitespaceClassDefinitionTest"
;;
*)
echo "Unexpected split index"
exit 1
;;
esac
echo "Expected: $EXPECTED"
echo "Actual: $ACTUAL"
if [ "$ACTUAL" != "$EXPECTED" ]; then
echo "The split tests are not matching"
exit 1
fi