-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest-coverage.ps1
More file actions
41 lines (31 loc) · 1.05 KB
/
test-coverage.ps1
File metadata and controls
41 lines (31 loc) · 1.05 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
#!/usr/bin/env pwsh
# test-coverage.ps1
$ErrorActionPreference = "Stop"
# Run tests and collect coverage
dotnet test src --collect:"XPlat Code Coverage" --settings src/coverlet.runsettings
# Find the most recent coverage file
$coverageFile = Get-ChildItem -Recurse -Filter "coverage.cobertura.xml" | Sort-Object LastWriteTime -Descending | Select-Object -First 1
if (-not $coverageFile) {
Write-Error "❌ No coverage file found."
exit 1
}
# Restore the report generator tool
dotnet tool restore --tool-manifest ./src/.config/dotnet-tools.json
# Generate the report
Push-Location ./src
dotnet tool run reportgenerator `
-reports:$coverageFile.FullName `
-targetdir:"../coverage" `
-reporttypes:"HtmlInline_AzurePipelines;TextSummary"
Pop-Location
# Open report in default browser
$indexPath = Join-Path "coverage" "index.html"
if ($IsWindows) {
Start-Process $indexPath
} elseif ($IsMacOS) {
open $indexPath
} elseif ($IsLinux) {
xdg-open $indexPath
} else {
Write-Warning "Platform not detected - open coverage/index.html manually"
}