-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathtest-coverage.sh
More file actions
executable file
·72 lines (59 loc) · 1.98 KB
/
test-coverage.sh
File metadata and controls
executable file
·72 lines (59 loc) · 1.98 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
69
70
71
72
#!/bin/bash
# Script to run tests with code coverage
set -e
echo "🧪 Running tests with code coverage..."
# Clean previous coverage results
rm -rf artifacts/coverage/
mkdir -p artifacts/coverage
# Run unit tests with coverage
echo "📊 Running unit tests with coverage..."
dotnet test test/UnitTests/UnitTests.csproj \
--collect:"XPlat Code Coverage" \
--results-directory:artifacts/coverage \
--logger:trx \
--verbosity normal
# Run integration tests with coverage
echo "🔧 Running integration tests with coverage..."
dotnet test test/IntegrationTests/IntegrationTests.csproj \
--collect:"XPlat Code Coverage" \
--results-directory:artifacts/coverage \
--logger:trx \
--verbosity normal
# Merge coverage reports if multiple exist
echo "📈 Processing coverage results..."
# Find all coverage files
coverage_files=$(find artifacts/coverage -name "*.xml" -type f)
coverage_count=$(echo "$coverage_files" | wc -l)
if [ $coverage_count -gt 0 ]; then
echo "✅ Found $coverage_count coverage file(s)"
# Install reportgenerator if not already installed
if ! command -v reportgenerator &> /dev/null; then
echo "📦 Installing ReportGenerator..."
dotnet tool install -g dotnet-reportgenerator-globaltool
fi
# Generate HTML report
echo "📄 Generating HTML coverage report..."
reportgenerator \
-reports:"artifacts/coverage/**/coverage.cobertura.xml" \
-targetdir:artifacts/coverage/html \
-reporttypes:Html \
-verbosity:Info
# Generate summary
reportgenerator \
-reports:"artifacts/coverage/**/coverage.cobertura.xml" \
-targetdir:artifacts/coverage \
-reporttypes:TextSummary \
-verbosity:Info
echo ""
echo "📊 Coverage Summary:"
echo "==================="
if [ -f "artifacts/coverage/Summary.txt" ]; then
cat artifacts/coverage/Summary.txt
fi
echo ""
echo "🌐 HTML Report: artifacts/coverage/html/index.html"
echo "📁 Coverage Files: artifacts/coverage/"
else
echo "❌ No coverage files found"
exit 1
fi