Skip to content

Commit

Permalink
Track code coverage (#452)
Browse files Browse the repository at this point in the history
* Add coverlet.collector to test projects
* Add steps to ci-official.yml to publish results

Addresses #397
  • Loading branch information
MarkZither authored Feb 16, 2020
1 parent 5f263e9 commit 9c5d281
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 1 deletion.
18 changes: 17 additions & 1 deletion .azure/pipelines/ci-official.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,23 @@ jobs:
inputs:
command: test
projects: '**/*Tests/*.csproj'
arguments: '--configuration $(BuildConfiguration)'
arguments: '--configuration $(BuildConfiguration) --settings $(System.DefaultWorkingDirectory)/CodeCoverage.runsettings --collect:"XPlat Code Coverage" -- RunConfiguration.DisableAppDomain=true'

- task: DotNetCoreCLI@2
inputs:
command: custom
custom: tool
arguments: install --tool-path . dotnet-reportgenerator-globaltool
displayName: Install ReportGenerator tool

- script: reportgenerator -reports:$(Agent.TempDirectory)/**/coverage.cobertura.xml -targetdir:$(Build.SourcesDirectory)/coverlet/reports -reporttypes:"HtmlInline_AzurePipelines_Dark;Cobertura;Badges"
displayName: Create reports

- task: PublishCodeCoverageResults@1
displayName: 'Publish code coverage'
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: $(Build.SourcesDirectory)/coverlet/reports/Cobertura.xml

- script: dotnet pack --configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)
displayName: Pack
Expand Down
16 changes: 16 additions & 0 deletions CodeCoverage.runsettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8" ?>
<RunSettings>
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="XPlat code coverage">
<Configuration>
<Format>json,cobertura</Format>
<ExcludeByAttribute>Obsolete,GeneratedCodeAttribute,CompilerGeneratedAttribute</ExcludeByAttribute>
<SingleHit>false</SingleHit>
<UseSourceLink>true</UseSourceLink>
<IncludeTestAssembly>true</IncludeTestAssembly>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
</RunSettings>
4 changes: 4 additions & 0 deletions tests/BaGet.Core.Tests/BaGet.Core.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="1.2.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 4 additions & 0 deletions tests/BaGet.Protocol.Tests/BaGet.Protocol.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="1.2.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 4 additions & 0 deletions tests/BaGet.Tests/BaGet.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="1.2.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 9c5d281

Please sign in to comment.