refactor/(run_all_tests.sh): add HTML report generation and display functionality

- Add HTML report generation step using mvn surefire-report:report-only
- Create dedicated html-reports directory in test results for organized report storage
- Copy surefire HTML reports from both obp-api and obp-commons modules
- Check multiple report locations (target/surefire-reports and target/site)
- Display generated HTML report paths in final test summary output
- Improve test result accessibility by centralizing HTML reports in one location
This commit is contained in:
hongwei 2026-01-09 12:25:30 +01:00
parent f2b9b2a33d
commit 2f68e00c2a

47
run_all_tests.sh Executable file → Normal file
View File

@ -817,6 +817,46 @@ else
RESULT_COLOR=""
fi
################################################################################
# GENERATE HTML REPORT
################################################################################
print_header "Generating HTML Report"
log_message "Running: mvn surefire-report:report-only -DskipTests"
# Generate HTML report from surefire XML files (without re-running tests)
if mvn surefire-report:report-only -DskipTests 2>&1 | tee -a "${DETAIL_LOG}"; then
log_message "[OK] HTML report generated"
# Copy HTML reports to test-results directory for easy access
HTML_REPORT_DIR="${LOG_DIR}/html-reports"
mkdir -p "${HTML_REPORT_DIR}"
# Copy reports from both modules
if [ -f "obp-api/target/surefire-reports/surefire-report.html" ]; then
cp "obp-api/target/surefire-reports/surefire-report.html" "${HTML_REPORT_DIR}/obp-api-report.html"
log_message " - obp-api report: ${HTML_REPORT_DIR}/obp-api-report.html"
fi
if [ -f "obp-commons/target/surefire-reports/surefire-report.html" ]; then
cp "obp-commons/target/surefire-reports/surefire-report.html" "${HTML_REPORT_DIR}/obp-commons-report.html"
log_message " - obp-commons report: ${HTML_REPORT_DIR}/obp-commons-report.html"
fi
# Also check for site reports location
if [ -f "obp-api/target/site/surefire-report.html" ]; then
cp "obp-api/target/site/surefire-report.html" "${HTML_REPORT_DIR}/obp-api-report.html"
log_message " - obp-api report: ${HTML_REPORT_DIR}/obp-api-report.html"
fi
if [ -f "obp-commons/target/site/surefire-report.html" ]; then
cp "obp-commons/target/site/surefire-report.html" "${HTML_REPORT_DIR}/obp-commons-report.html"
log_message " - obp-commons report: ${HTML_REPORT_DIR}/obp-commons-report.html"
fi
else
log_message "[WARNING] Failed to generate HTML report"
fi
log_message ""
# Stop background monitor by removing flag file
rm -f "${MONITOR_FLAG}"
sleep 1
@ -862,6 +902,13 @@ log_message " ${SUMMARY_LOG}"
if [ -f "${FAILED_TESTS_FILE}" ]; then
log_message " ${FAILED_TESTS_FILE}"
fi
if [ -d "${LOG_DIR}/html-reports" ]; then
log_message ""
log_message "HTML Reports:"
for report in "${LOG_DIR}/html-reports"/*.html; do
[ -f "$report" ] && log_message " $report"
done
fi
echo ""
exit ${EXIT_CODE}