forked from gui-cs/Terminal.Gui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRun-LocalCoverage.ps1
More file actions
108 lines (94 loc) · 4.06 KB
/
Run-LocalCoverage.ps1
File metadata and controls
108 lines (94 loc) · 4.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# ------------------------------------------------------------
# Run-LocalCoverage.ps1
# Local-only: Unit + Parallel + Integration tests
# Quiet, merged coverage in /Tests
# ------------------------------------------------------------
# 1. Define paths
$testDir = Join-Path $PWD "Tests"
$covDir = Join-Path $testDir "coverage"
$reportDir = Join-Path $testDir "report"
$resultsDir = Join-Path $testDir "TestResults"
$mergedFile = Join-Path $covDir "coverage.merged.cobertura.xml"
# 2. Clean old results - INCLUDING TestResults directory
Write-Host "Cleaning old coverage files and test results..."
Remove-Item -Recurse -Force $covDir, $reportDir, $resultsDir -ErrorAction SilentlyContinue
New-Item -ItemType Directory -Path $covDir, $reportDir -Force | Out-Null
dotnet build --configuration Debug --no-restore
# ------------------------------------------------------------
# 3. Run UNIT TESTS (non-parallel)
# ------------------------------------------------------------
Write-Host "`nRunning UnitTests (quiet)..."
dotnet test Tests/UnitTests `
--no-build `
--verbosity minimal `
--collect:"XPlat Code Coverage" `
--settings Tests/UnitTests/runsettings.coverage.xml
# ------------------------------------------------------------
# 4. Run UNIT TESTS (parallel)
# ------------------------------------------------------------
Write-Host "`nRunning UnitTestsParallelizable (quiet)..."
dotnet test Tests/UnitTestsParallelizable `
--no-build `
--verbosity minimal `
--collect:"XPlat Code Coverage" `
--settings Tests/UnitTestsParallelizable/runsettings.coverage.xml
# ------------------------------------------------------------
# 5. Run INTEGRATION TESTS
# ------------------------------------------------------------
Write-Host "`nRunning IntegrationTests (quiet)..."
dotnet test Tests/IntegrationTests `
--no-build `
--verbosity minimal `
--collect:"XPlat Code Coverage" `
--settings Tests/IntegrationTests/runsettings.coverage.xml
# ------------------------------------------------------------
# 6. Find ALL coverage files (from all 3 projects) - NOW SCOPED TO Tests/TestResults
# ------------------------------------------------------------
Write-Host "`nCollecting coverage files..."
$covFiles = Get-ChildItem -Path $resultsDir -Recurse -Filter coverage.cobertura.xml -File -ErrorAction SilentlyContinue
if (-not $covFiles) {
Write-Error "No coverage files found in $resultsDir. Did all tests run successfully?"
exit 1
}
# ------------------------------------------------------------
# 7. Move to Tests/coverage
# ------------------------------------------------------------
Write-Host "Moving $($covFiles.Count) coverage file(s) to $covDir..."
$fileIndex = 1
foreach ($f in $covFiles) {
$destFile = Join-Path $covDir "coverage.$fileIndex.cobertura.xml"
Copy-Item $f.FullName -Destination $destFile -Force
$fileIndex++
}
# ------------------------------------------------------------
# 8. Merge into one file
# ------------------------------------------------------------
Write-Host "Merging coverage from all test projects..."
dotnet-coverage merge `
-o $mergedFile `
-f cobertura `
"$covDir\*.cobertura.xml"
# ------------------------------------------------------------
# 9. Generate HTML + text report
# ------------------------------------------------------------
Write-Host "Generating final HTML report..."
reportgenerator `
-reports:$mergedFile `
-targetdir:$reportDir `
-reporttypes:"Html;TextSummary"
# ------------------------------------------------------------
# 10. Show summary + open report
# ------------------------------------------------------------
Write-Host "`n=== Final Coverage Summary (Unit + Integration) ==="
Get-Content "$reportDir\Summary.txt"
$indexHtml = Join-Path $reportDir "index.html"
if (Test-Path $indexHtml) {
Write-Host "Opening report in browser..."
Start-Process $indexHtml
} else {
Write-Warning "HTML report not found at $indexHtml"
}
Write-Host "`nCoverage artifacts:"
Write-Host " - Merged coverage: $mergedFile"
Write-Host " - HTML report: $reportDir\index.html"
Write-Host " - Test results: $resultsDir"