-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcoverage.ps1
More file actions
36 lines (28 loc) Β· 1.34 KB
/
Copy pathcoverage.ps1
File metadata and controls
36 lines (28 loc) Β· 1.34 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
$solutionDir = $PSScriptRoot
$testProjects = @(
"tests\Kuker.Analyzers.Tests\Kuker.Analyzers.Tests.csproj",
"tests\Kuker.CodeFixes.Tests\Kuker.CodeFixes.Tests.csproj"
)
$reportDir = "$solutionDir\coverage-report"
Write-Host "Running tests with coverage..." -ForegroundColor Cyan
foreach ($project in $testProjects) {
$projectPath = Join-Path $solutionDir $project
Write-Host "Testing: $project" -ForegroundColor Yellow
dotnet test $projectPath --no-build --verbosity normal --collect:"XPlat Code Coverage"
}
Write-Host "Collecting coverage files..." -ForegroundColor Cyan
$xmlFiles = Get-ChildItem -Path $solutionDir\tests -Recurse -Filter "coverage.cobertura.xml" |
Sort-Object LastWriteTime -Descending |
Group-Object { $_.FullName -replace "\\TestResults\\.*", "" } |
ForEach-Object { $_.Group | Select-Object -First 1 }
if (-not $xmlFiles) {
Write-Host "No coverage files found!" -ForegroundColor Red
exit 1
}
$reports = ($xmlFiles.FullName) -join ";"
Write-Host "Found coverage files:" -ForegroundColor Cyan
$xmlFiles.FullName | ForEach-Object { Write-Host " $_" -ForegroundColor Gray }
Write-Host "Generating HTML report..." -ForegroundColor Cyan
reportgenerator -reports:$reports -targetdir:$reportDir -reporttypes:Html
Write-Host "Opening report..." -ForegroundColor Green
Start-Process "$reportDir\index.html"