Skip to content

Commit c9e574e

Browse files
committed
feat(tests): switch to XPlat Code Coverage (coverlet.collector) for coverage report generation
1 parent a2b5532 commit c9e574e

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

.github/workflows/dotnet.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
uses: actions/checkout@v4
4747

4848
- name: Run tests and generate Cobertura coverage reports
49-
run: dotnet test --results-directory "coverage" --collect:"Code Coverage;Format=cobertura" --settings .runsettings
49+
run: dotnet test --results-directory "coverage" --collect:"XPlat Code Coverage" --settings .runsettings
5050

5151
- name: Install dotnet-coverage tool
5252
run: dotnet tool install --global dotnet-coverage

.runsettings

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22
<RunSettings>
33
<DataCollectionRunSettings>
44
<DataCollectors>
5-
<DataCollector friendlyName="Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0">
5+
<DataCollector friendlyName="XPlat Code Coverage">
66
<Configuration>
7+
<Format>cobertura</Format>
8+
<SkipAutoProps>true</SkipAutoProps>
9+
<BasePath>$(MSBuildProjectDirectory)</BasePath>
710
<CodeCoverage>
8-
<!-- Exclude all test projects -->
911
<ModulePaths>
12+
<!-- Exclude all test projects -->
1013
<Exclude>
1114
<ModulePath>.*\.Tests\.dll$</ModulePath>
1215
</Exclude>

test/Dotnet.Samples.AspNetCore.WebApi.Tests/Dotnet.Samples.AspNetCore.WebApi.Tests.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12+
<PackageReference Include="coverlet.collector" Version="6.0.4">
13+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
14+
<PrivateAssets>all</PrivateAssets>
15+
</PackageReference>
1216
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
1317
<PackageReference Include="xunit" Version="2.9.3" />
1418
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.2">

test/Dotnet.Samples.AspNetCore.WebApi.Tests/packages.lock.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
"version": 1,
33
"dependencies": {
44
"net8.0": {
5+
"coverlet.collector": {
6+
"type": "Direct",
7+
"requested": "[6.0.4, )",
8+
"resolved": "6.0.4",
9+
"contentHash": "lkhqpF8Pu2Y7IiN7OntbsTtdbpR1syMsm2F3IgX6ootA4ffRqWL5jF7XipHuZQTdVuWG/gVAAcf8mjk8Tz0xPg=="
10+
},
511
"FluentAssertions": {
612
"type": "Direct",
713
"requested": "[8.2.0, )",

0 commit comments

Comments
 (0)