-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcoverage.sh
More file actions
executable file
·68 lines (53 loc) · 2.06 KB
/
coverage.sh
File metadata and controls
executable file
·68 lines (53 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
# Script for local code coverage report generation for Reliable.HttpClient
set -e # Stop execution on error
echo "🧪 Running Reliable.HttpClient tests with coverage generation..."
# Clean previous results
rm -rf ./TestResults ./CoverageReport
# Run tests for the entire solution with coverage
dotnet test Reliable.HttpClient.sln \
--configuration Release \
--collect:"XPlat Code Coverage" \
--results-directory ./TestResults \
--verbosity minimal
echo "📊 Generating HTML report..."
# Install report generation tool (if not installed)
dotnet tool restore > /dev/null 2>&1
if ! command -v reportgenerator &> /dev/null; then
echo "🔧 Installing reportgenerator..."
dotnet tool install --global dotnet-reportgenerator-globaltool
fi
# Collect all coverage files
COVERAGE_FILES=$(find ./TestResults -name "coverage.cobertura.xml" -type f)
if [ -z "$COVERAGE_FILES" ]; then
echo "❌ Coverage files not found!"
echo "Check that tests executed successfully and coverlet.collector is installed."
exit 1
fi
echo "📁 Found coverage files:"
echo "$COVERAGE_FILES" | sed 's/^/ - /'
# Create string with all coverage files for reportgenerator
COVERAGE_REPORTS=$(echo "$COVERAGE_FILES" | tr '\n' ';' | sed 's/;$//')
# Generate HTML report with all projects combined
reportgenerator \
-reports:"$COVERAGE_REPORTS" \
-targetdir:"./CoverageReport" \
-reporttypes:"Html;TextSummary" \
-assemblyfilters:"+Reliable.HttpClient*;-*.Tests*" \
-classfilters:"-*.Tests*"
echo ""
echo "✅ HTML report created at ./CoverageReport/index.html"
echo "🌐 Open the file in browser to view:"
echo " file://$(pwd)/CoverageReport/index.html"
# Show brief statistics
if [ -f "./CoverageReport/Summary.txt" ]; then
echo ""
echo "📈 Brief coverage statistics:"
echo "======================================="
cat ./CoverageReport/Summary.txt
echo "======================================="
else
echo "⚠️ Could not retrieve brief statistics"
fi
echo ""
echo "🎯 Tip: Add ./TestResults and ./CoverageReport to .gitignore"