Skip to content

Commit 3c8cbe7

Browse files
author
Bart Koelman
committed
Setup code coverage
1 parent c7edd3e commit 3c8cbe7

File tree

5 files changed

+32
-8
lines changed

5 files changed

+32
-8
lines changed

.config/dotnet-tools.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@
1313
"commands": [
1414
"regitlint"
1515
]
16+
},
17+
"codecov.tool": {
18+
"version": "1.13.0",
19+
"commands": [
20+
"codecov"
21+
]
22+
},
23+
"dotnet-reportgenerator-globaltool": {
24+
"version": "4.8.7",
25+
"commands": [
26+
"reportgenerator"
27+
]
1628
}
1729
}
1830
}

Build.ps1

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,17 @@ function RunCleanupCode {
6363
}
6464
}
6565

66+
function ReportCodeCoverage {
67+
if ($env:APPVEYOR) {
68+
dotnet codecov -f "**\coverage.cobertura.xml"
69+
}
70+
else {
71+
dotnet reportgenerator -reports:**\coverage.cobertura.xml -targetdir:artifacts\coverage
72+
}
73+
74+
CheckLastExitCode
75+
}
76+
6677
$revision = @{ $true = $env:APPVEYOR_BUILD_NUMBER; $false = 1 }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL];
6778
$revision = "{0:D4}" -f [convert]::ToInt32($revision, 10)
6879

@@ -75,9 +86,11 @@ CheckLastExitCode
7586
RunInspectCode
7687
RunCleanupCode
7788

78-
dotnet test -c Release --no-build
89+
dotnet test -c Release --no-build --collect:"XPlat Code Coverage"
7990
CheckLastExitCode
8091

92+
ReportCodeCoverage
93+
8194
Write-Output "APPVEYOR_REPO_TAG: $env:APPVEYOR_REPO_TAG"
8295

8396
if ($env:APPVEYOR_REPO_TAG -eq $true) {

Directory.Build.props

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@
2121

2222
<!-- Test Project Dependencies -->
2323
<PropertyGroup>
24-
<XUnitVersion>2.4.1</XUnitVersion>
25-
<FluentAssertionsVersion>5.10.3</FluentAssertionsVersion>
2624
<BogusVersion>33.0.2</BogusVersion>
25+
<CoverletVersion>3.0.3</CoverletVersion>
26+
<FluentAssertionsVersion>5.10.3</FluentAssertionsVersion>
2727
<MoqVersion>4.16.1</MoqVersion>
28+
<XUnitVersion>2.4.1</XUnitVersion>
2829
</PropertyGroup>
2930
</Project>

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
Plug-n-play implementation of `IResourceRepository<TResource, TId>` allowing you to use [MongoDB](https://www.mongodb.com/) with your [JsonApiDotNetCore](https://github.com/json-api-dotnet/JsonApiDotNetCore) APIs.
44

5-
[![Build status](https://ci.appveyor.com/api/projects/status/dadm2kr2y0353mji/branch/master?svg=true)](https://ci.appveyor.com/project/json-api-dotnet/jsonapidotnetcore-mongodb/branch/master)
5+
[![Build](https://ci.appveyor.com/api/projects/status/dadm2kr2y0353mji/branch/master?svg=true)](https://ci.appveyor.com/project/json-api-dotnet/jsonapidotnetcore-mongodb/branch/master)
6+
[![codecov](https://codecov.io/gh/json-api-dotnet/JsonApiDotNetCore.MongoDb/branch/master/graph/badge.svg?token=QPVf8rii7l)](https://codecov.io/gh/json-api-dotnet/JsonApiDotNetCore.MongoDb)
67
[![NuGet](https://img.shields.io/nuget/v/JsonApiDotNetCore.MongoDb.svg)](https://www.nuget.org/packages/JsonApiDotNetCore.MongoDb/)
78

89
## Installation and Usage

test/JsonApiDotNetCoreMongoDbExampleTests/JsonApiDotNetCoreMongoDbExampleTests.csproj

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@
1616

1717
<ItemGroup>
1818
<PackageReference Include="Bogus" Version="31.0.3" />
19-
<PackageReference Include="coverlet.msbuild" Version="2.9.0">
20-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
21-
<PrivateAssets>all</PrivateAssets>
22-
</PackageReference>
19+
<PackageReference Include="coverlet.collector" Version="$(CoverletVersion)" PrivateAssets="All" />
2320
<PackageReference Include="FluentAssertions" Version="$(FluentAssertionsVersion)" />
2421
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="3.1.9" />
2522
<PackageReference Include="Mongo2Go" Version="2.2.16" />

0 commit comments

Comments
 (0)