setup coverate report generation
This commit is contained in:
50
run-coverage.sh
Normal file
50
run-coverage.sh
Normal file
@ -0,0 +1,50 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Script to generate code coverage reports using Docker
|
||||
|
||||
echo "================================================================================"
|
||||
echo "Generating Code Coverage Reports"
|
||||
echo "================================================================================"
|
||||
echo ""
|
||||
|
||||
# Clean previous reports
|
||||
if [ -d "target/site/jacoco" ]; then
|
||||
echo "Cleaning previous coverage reports..."
|
||||
rm -rf target/site/jacoco
|
||||
echo ""
|
||||
fi
|
||||
|
||||
# Run tests with coverage
|
||||
docker-compose -f docker-compose.coverage.yml up --build
|
||||
|
||||
echo ""
|
||||
echo "================================================================================"
|
||||
echo "Coverage Report Generated"
|
||||
echo "================================================================================"
|
||||
echo ""
|
||||
echo "HTML Report: target/site/jacoco/index.html"
|
||||
echo "XML Report: target/site/jacoco/jacoco.xml"
|
||||
echo "CSV Report: target/site/jacoco/jacoco.csv"
|
||||
echo ""
|
||||
echo "Open the HTML report in your browser to view coverage details."
|
||||
echo ""
|
||||
|
||||
# Clean up the coverage container
|
||||
docker-compose -f docker-compose.coverage.yml down
|
||||
|
||||
# Ask user if they want to open the report (for systems with xdg-open)
|
||||
read -p "Would you like to open the coverage report now? (y/n): " OPEN_REPORT
|
||||
if [ "$OPEN_REPORT" = "y" ] || [ "$OPEN_REPORT" = "Y" ]; then
|
||||
if [ -f "target/site/jacoco/index.html" ]; then
|
||||
# Try to open with default browser
|
||||
if command -v xdg-open > /dev/null; then
|
||||
xdg-open target/site/jacoco/index.html
|
||||
elif command -v open > /dev/null; then
|
||||
open target/site/jacoco/index.html
|
||||
else
|
||||
echo "Please open target/site/jacoco/index.html manually in your browser."
|
||||
fi
|
||||
else
|
||||
echo "Error: Coverage report not found!"
|
||||
fi
|
||||
fi
|
||||
Reference in New Issue
Block a user