Skip to content

Commit 3f13ca4

Browse files
authored
chore: Generate a code coverage report for command line builds (#4)
1 parent fa3677f commit 3f13ca4

5 files changed

Lines changed: 30 additions & 2 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
CoverageReport
12
launchSettings.json
23

34
## Ignore Visual Studio temporary files, build results, and

build

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ function write_error {
88

99
builtin type -P dotnet &>/dev/null || write_error "Could not find 'dotnet'; please install the .NET SDK from https://dot.net/"
1010

11+
dotnet tool restore
1112
dotnet restore
1213
dotnet build --no-restore --configuration Release
13-
dotnet test --no-build --configuration Release
14+
dotnet test --no-build --configuration Release --coverage --coverage-output-format cobertura --coverage-output coverage.cobertura.xml
15+
dotnet reportgenerator -reports:**/TestResults/**/coverage.cobertura.xml -targetdir:CoverageReport -reporttypes:"TextSummary" -verbosity:off
16+
echo ""
17+
echo -e "\e[32mCode coverage report:\e[0m"
18+
echo ""
19+
cat CoverageReport/Summary.txt

build.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ if ($null -eq (Get-Command "dotnet" -ErrorAction Ignore)) {
88
throw "Could not find 'dotnet'; please install the .NET SDK from https://dot.net/"
99
}
1010

11+
dotnet tool restore
1112
dotnet restore
1213
dotnet build --no-restore --configuration Release
13-
dotnet test --no-build --configuration Release
14+
dotnet test --no-build --configuration Release --coverage --coverage-output-format cobertura --coverage-output coverage.cobertura.xml
15+
dotnet reportgenerator -reports:**/TestResults/**/coverage.cobertura.xml -targetdir:CoverageReport -reporttypes:"TextSummary" -verbosity:off
16+
Write-Host ""
17+
Write-Host "Code coverage report:" -ForegroundColor DarkGreen
18+
Write-Host ""
19+
Get-Content CoverageReport/Summary.txt

dotnet-sdk.slnx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
<Folder Name="/meta/">
33
<File Path=".editorconfig" />
44
<File Path=".gitignore" />
5+
<File Path="build" />
6+
<File Path="build.ps1" />
57
<File Path="global.json" />
68
<File Path="README.md" />
79
</Folder>

dotnet-tools.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"version": 1,
3+
"isRoot": true,
4+
"tools": {
5+
"dotnet-reportgenerator-globaltool": {
6+
"version": "5.5.1",
7+
"commands": [
8+
"reportgenerator"
9+
],
10+
"rollForward": false
11+
}
12+
}
13+
}

0 commit comments

Comments
 (0)