-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodeCoverage.ps1
More file actions
38 lines (29 loc) · 1.26 KB
/
CodeCoverage.ps1
File metadata and controls
38 lines (29 loc) · 1.26 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
#Requires -Version 7.4
[CmdletBinding()]
param (
# Opens the html report (in your default browser).
[Parameter()]
[switch]$Open
)
Set-StrictMode -Version 3.0
$ErrorActionPreference = 'Stop'
$PSNativeCommandUseErrorActionPreference = $true
$ReportDir = 'coverage-report'
$CoverageDir = 'coverage'
$DocsDir = '.\docs\coverage'
# remove old coverage data and reports
Remove-Item $CoverageDir -Recurse -ErrorAction Ignore
Remove-Item $ReportDir -Recurse -ErrorAction Ignore
New-Item -Type Directory $CoverageDir -ErrorAction Ignore
dotnet build
dotnet build .\Tests\Dummies\Dummies.slnx
dotnet test --no-build --coverage --coverage-output-format 'xml' --results-directory $CoverageDir --coverage-settings 'CodeCoverage.xml' -p:PublishAot=false
# create the report
dotnet tool restore
dotnet ReportGenerator -Reports:"$CoverageDir/*" -TargetDir:"$ReportDir" -ReportTypes:'HtmlInline;MarkdownSummaryGithub;Badges'
Get-Content (Join-Path $ReportDir 'SummaryGithub.md') | Select-String -NotMatch 'Feature is only available for sponsors|Generated on' | Set-Content (Join-Path $DocsDir 'SummaryGithub.md')
# cspell:ignore linecoverage
Copy-Item (Join-Path $ReportDir 'badge_linecoverage.svg') -Destination $DocsDir -Force
if ($Open) {
Invoke-Item (Join-Path $ReportDir 'index.html')
}