Skip to content

Commit daa4ad1

Browse files
committed
Fix code coverage collection with VSTest
1 parent 9a1962f commit daa4ad1

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ jobs:
3535
run: dotnet build -c Release --no-restore
3636
- name: Test & collect coverage
3737
run: |
38-
dotnet test -c Release --no-restore --no-build -- \
39-
--coverage --coverage-output-format xml --coverage-output ${{ github.workspace }}/coverage.xml
38+
dotnet test -c Release --no-restore --no-build \
39+
--collect "Code Coverage;Format=cobertura" --results-directory ${{ github.workspace }}/coverage.xml
4040
env:
4141
USE_MOCKING: ${{ vars.USE_MOCKING }}
4242
SHOW_MOCKING_LOGS: ${{ vars.SHOW_MOCKING_LOGS }}
4343
- name: Find coverage files and generate report
4444
run: |
45-
dotnet tool run reportgenerator -reports:"${{ github.workspace }}/**/coverage.xml" \
45+
dotnet tool run reportgenerator -reports:"${{ github.workspace }}/**/*cobertura.xml" \
4646
-targetdir:"coverage-report" \
4747
-reporttypes:MarkdownSummaryGithub
4848
- name: Upload coverage report

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ bld/
2727

2828
# Coverage
2929
[Cc]overagereport
30-
coverage.*.xml
30+
*coverage.*.xml
31+
*cobertura.xml
3132

3233
# PDFs
3334
*.pdf

coverage.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
dotnet test -c Debug --no-restore --no-build -- --coverage --coverage-output-format xml --coverage-output coverage.xml
1+
dotnet test -c Debug --no-restore --no-build --collect "Code Coverage;Format=cobertura" --results-directory TestResults
22

3-
$coverageFiles = Get-ChildItem -Path "tests" -Recurse -Filter "coverage.xml"
3+
$coverageFiles = Get-ChildItem -Path "TestResults" -Recurse -Filter "*.cobertura.xml"
44

55
if ($coverageFiles) {
66
$reportFiles = ($coverageFiles | ForEach-Object { $_.FullName }) -join ";"
@@ -11,4 +11,4 @@ if ($coverageFiles) {
1111
Write-Host "Coverage reports not found."
1212
}
1313

14-
Get-ChildItem -Path "tests" -Recurse -Filter "TestResults" | ForEach-Object { Remove-Item -Recurse -Force -Path $_.FullName }
14+
Get-ChildItem -Path "TestResults" -Recurse | ForEach-Object { Remove-Item -Recurse -Force -Path $_.FullName }

0 commit comments

Comments
 (0)