Skip to content

Commit 2c3ff9a

Browse files
committed
ci: enhance test reporting
- Add conditional check for empty JUnit report files - Update command to handle cases with no tests found - Ensure max score defaults to 0 if no tests are executed
1 parent 2ac48b5 commit 2c3ff9a

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

.github/workflows/classroom-autograding.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,30 @@ jobs:
2020
cache: maven
2121

2222
- name: Run tests with Maven Wrapper
23+
id: test
2324
run: |
2425
chmod +x mvnw
2526
./mvnw test -B
2627
continue-on-error: true
2728

2829
- name: Parse JUnit results
2930
id: parse
30-
if: always()
31+
if: always() && success() || failure()
3132
uses: dorny/test-reporter@v2
3233
with:
3334
name: JUnit Results
3435
path: "**/target/surefire-reports/**/*.xml"
3536
reporter: java-junit
37+
fail-on-empty: false
3638

3739
- name: Report score back to Classroom
3840
uses: github-education-resources/autograding-command-grader@v1
3941
with:
4042
test-name: JUnit-Suite
41-
command: echo "Passed ${{ steps.parse.outputs.passed }} of ${{ steps.parse.outputs.total }} tests"
42-
max-score: ${{ steps.parse.outputs.total }}
43+
command: |
44+
if [ -z "$(find . -path '**/target/surefire-reports/**/*.xml' -type f)" ]; then
45+
echo "Passed 0 of 0 tests"
46+
else
47+
echo "Passed ${{ steps.parse.outputs.passed }} of ${{ steps.parse.outputs.total }} tests"
48+
fi
49+
max-score: ${{ steps.parse.outputs.total || 0 }}

0 commit comments

Comments
 (0)