Skip to content

Commit

Permalink
Use coverlet for code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Oren Novotny committed Sep 4, 2019
1 parent 8512e81 commit cdc95df
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 25 deletions.
24 changes: 21 additions & 3 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ variables:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true

steps:
- task: DotNetCoreInstaller@0
- task: UseDotNet@2
displayName: 'Use .NET Core SDK 3.x'
inputs:
version: '2.2.105'
version: 3.x
includePreviewVersions: true

- task: DotNetCoreCLI@2
inputs:
Expand Down Expand Up @@ -48,8 +50,24 @@ steps:
inputs:
command: test
projects: .\src\Humanizer.Tests\Humanizer.Tests.csproj
arguments: -c $(BuildConfiguration) --collect:"Code Coverage" -s $(System.DefaultWorkingDirectory)/src/CodeCoverage.runsettings /p:DebugType=portable
arguments: -c $(BuildConfiguration) --collect:"XPlat code coverage" -s $(System.DefaultWorkingDirectory)/src/CodeCoverage.runsettings -- RunConfiguration.DisableAppDomain=true
displayName: Run Tests

- 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)/Rx.NET/Source/coverlet/reports -reporttypes:"Cobertura"
displayName: Create reports

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

- task: PowerShell@2
displayName: Authenticode Sign artifacts
Expand Down
27 changes: 5 additions & 22 deletions src/CodeCoverage.runsettings
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,12 @@
<RunSettings>
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0" assemblyQualifiedName="Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector, Microsoft.VisualStudio.TraceCollector, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<DataCollector friendlyName="XPlat code coverage">
<Configuration>
<CodeCoverage>

<!--
About include/exclude lists:
Empty "Include" clauses imply all; empty "Exclude" clauses imply none.
Each element in the list is a regular expression (ECMAScript syntax). See http://msdn.microsoft.com/library/2k3te2cs.aspx.
An item must first match at least one entry in the include list to be included.
Included items must then not match any entries in the exclude list to remain included.
-->

<!-- Match assembly file paths: -->
<ModulePaths>
<Include>
<ModulePath>.*Humanizer.*\.dll$</ModulePath>
</Include>
<Exclude>
<ModulePath>.*Tests.*</ModulePath>
</Exclude>
</ModulePaths>

</CodeCoverage>
<Format>cobertura</Format>
<Exclude>[xunit.*]*,[*Tests]*,[*]Xunit.*</Exclude> <!-- [Assembly-Filter]Type-Filter -->
<ExcludeByAttribute>Obsolete,GeneratedCodeAttribute,CompilerGeneratedAttribute</ExcludeByAttribute>
<SingleHit>false</SingleHit>
</Configuration>
</DataCollector>
</DataCollectors>
Expand Down
1 change: 1 addition & 0 deletions src/Humanizer.Tests/Humanizer.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<DefineConstants>$(DefineConstants);NETFX_CORE</DefineConstants>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="1.0.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
Expand Down

0 comments on commit cdc95df

Please sign in to comment.