Skip to content

Commit 42a3258

Browse files
committed
fix : fix tests
1 parent 1f0dd1f commit 42a3258

File tree

2 files changed

+62
-24
lines changed

2 files changed

+62
-24
lines changed

.github/workflows/gradle.yml

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,30 +40,49 @@ jobs:
4040
run: ./gradlew build --info
4141

4242
- name: Run tests with detailed output
43+
id: run_tests
4344
run: ./gradlew test --info --continue --stacktrace
44-
continue-on-error: false
45+
continue-on-error: true
4546

4647
- name: Print detailed test failures
47-
if: failure()
48+
if: always()
4849
run: |
49-
echo "🔍 ANALYZING TEST FAILURES..."
50-
echo ""
51-
52-
# Run custom Gradle task to print failed tests
53-
./gradlew printFailedTests || true
54-
50+
echo "🔍 ANALYZING TEST RESULTS..."
5551
echo ""
56-
echo "📊 ADDITIONAL FAILURE DETAILS:"
5752
58-
# Extract failed tests from XML reports with more details
59-
find build/test-results -name "*.xml" -exec grep -l "failures=\"[1-9]" {} \; | while read file; do
60-
echo "📁 From $file:"
61-
grep -A 10 -B 2 '<failure' "$file" | sed 's/^/ /' || true
53+
# Check if there were test failures
54+
if [ -d "build/test-results/test" ]; then
55+
# Run custom Gradle task to print failed tests
56+
echo "📋 RUNNING CUSTOM FAILURE ANALYSIS:"
57+
./gradlew printFailedTests || true
58+
6259
echo ""
63-
done
64-
65-
echo "📊 TEST REPORTS AVAILABLE:"
66-
find build/reports/tests -name "index.html" -exec echo " 📄 {}" \; || true
60+
echo "📊 EXTRACTING FAILURE DETAILS FROM XML:"
61+
62+
# Extract failed tests from XML reports with more details
63+
find build/test-results -name "*.xml" -exec grep -l "failures=\"[1-9]" {} \; | while read file; do
64+
echo "📁 From $file:"
65+
echo " Failed test cases:"
66+
grep -A 15 -B 2 '<failure' "$file" | sed 's/^/ /' || true
67+
echo ""
68+
done
69+
70+
echo "📊 TEST REPORTS AVAILABLE:"
71+
find build/reports/tests -name "index.html" -exec echo " 📄 {}" \; || true
72+
73+
# Count failures
74+
FAILURES=$(find build/test-results -name "*.xml" -exec grep -c "failures=\"[1-9]" {} \; 2>/dev/null | awk '{sum+=$1} END {print sum+0}')
75+
echo ""
76+
echo "🔢 TOTAL FAILED TEST CLASSES: $FAILURES"
77+
else
78+
echo "ℹ️ No test results directory found"
79+
fi
80+
81+
- name: Fail if tests failed
82+
if: steps.run_tests.outcome == 'failure'
83+
run: |
84+
echo "❌ Tests failed - failing the workflow"
85+
exit 1
6786
6887
- name: Upload test reports
6988
uses: actions/upload-artifact@v4

build.gradle

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,26 @@ test {
2626
useJUnitPlatform()
2727
finalizedBy jacocoTestReport
2828

29-
// Enhanced test reporting - focus on failures
29+
// Enhanced test reporting - simple and effective
3030
testLogging {
31+
// Always show these events regardless of log level
3132
events "failed", "skipped"
3233
exceptionFormat "full"
3334
showCauses true
3435
showExceptions true
3536
showStackTraces true
3637
showStandardStreams = false
3738

38-
// Only show details for failed tests
39+
// More details when running with --info
3940
info {
40-
events "failed", "skipped"
41+
events "started", "passed", "failed", "skipped"
4142
exceptionFormat "full"
4243
}
4344

44-
// Quiet mode but still show failures
45-
quiet {
46-
events "failed", "skipped"
45+
// Debug level for complete output
46+
debug {
47+
events "started", "passed", "skipped", "failed", "standardOut", "standardError"
48+
exceptionFormat "full"
4749
}
4850
}
4951

@@ -64,17 +66,34 @@ test {
6466
}
6567
}
6668

69+
// Track test execution (optional - can be removed if too verbose)
70+
beforeTest { desc ->
71+
if (logger.isInfoEnabled()) {
72+
println("🧪 Running: ${desc.className}.${desc.name}")
73+
}
74+
}
75+
6776
// Print details for each failed test
6877
afterTest { desc, result ->
6978
if (result.resultType == TestResult.ResultType.FAILURE) {
70-
println("\n❌ FAILED: ${desc.className}.${desc.name}")
79+
def border = "=" * 80
80+
println("\n${border}")
81+
println("❌ FAILED TEST: ${desc.className}.${desc.name}")
82+
println(" Duration: ${result.endTime - result.startTime}ms")
7183
if (result.exception) {
7284
println(" Exception: ${result.exception.class.simpleName}")
7385
println(" Message: ${result.exception.message}")
7486
if (result.exception.cause) {
7587
println(" Cause: ${result.exception.cause.message}")
7688
}
89+
if (result.exception.stackTrace) {
90+
println(" Stack Trace:")
91+
result.exception.stackTrace.take(5).each { trace ->
92+
println(" at ${trace}")
93+
}
94+
}
7795
}
96+
println("${border}")
7897
}
7998
}
8099
}

0 commit comments

Comments
 (0)