Pipeline: Add code coverage (#7799)

This commit is contained in:
junglebus 2020-03-22 16:40:58 +11:00 committed by GitHub
parent 6eaaa419f6
commit 38fddab2ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 13 deletions

View File

@ -313,15 +313,6 @@ stages:
projects: '**/*.Test*/*.csproj'
arguments: '--configuration $(buildConfiguration) --runtime $(runtime) --framework $(framework)'
- task: DotNetCoreCLI@2
displayName: Unit Tests (Windows only)
condition: and(succeeded(), startsWith(variables['runtime'], 'win'))
inputs:
command: test
projects: '**/*.Test*/*.csproj'
arguments: '--configuration $(buildConfiguration) --framework $(framework)'
testRunTitle: 'Unit - $(buildDescription) - $(Build.BuildId)'
- task: DotNetCoreCLI@2
displayName: Unit Tests (Mono, Linux and macOS)
condition: and(succeeded(), not(startsWith(variables['runtime'], 'win')))
@ -331,6 +322,37 @@ stages:
arguments: '--configuration $(buildConfiguration) --framework $(framework) --runtime $(runtime)'
testRunTitle: 'Unit - $(buildDescription) - $(Build.BuildId)'
- task: DotNetCoreCLI@2
displayName: Unit Tests & Code Coverage (Windows only)
condition: and(succeeded(), startsWith(variables['runtime'], 'win'))
inputs:
command: test
projects: '**/*.Test*/*.csproj'
arguments: '--configuration $(buildConfiguration) --framework $(framework) /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura'
testRunTitle: 'Unit - $(buildDescription) - $(Build.BuildId)'
- task: DotNetCoreCLI@2
displayName: Install Coverage ReportGenerator Tool (Windows only)
condition: and(succeeded(), startsWith(variables['runtime'], 'win'))
inputs:
command: custom
custom: tool
arguments: install --tool-path . dotnet-reportgenerator-globaltool
- task: PowerShell@2
displayName: Generate Coverage Report (Windows only)
condition: and(succeeded(), startsWith(variables['runtime'], 'win'))
inputs:
targetType: inline
script: ./reportgenerator -reports:$(Build.SourcesDirectory)/src/*.Test*/coverage.*.cobertura.xml -targetdir:$(Build.SourcesDirectory)/coverlet/reports -reporttypes:"Cobertura"
- task: PublishCodeCoverageResults@1
displayName: Publish Code Coverage (Windows only)
condition: and(succeeded(), startsWith(variables['runtime'], 'win'))
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: $(Build.SourcesDirectory)/coverlet/reports/Cobertura.xml
- stage: Integration
displayName: Integration Tests

View File

@ -12,10 +12,6 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.1.0" />
<PackageReference Include="MSTest.TestFramework" Version="2.1.0" />
<PackageReference Include="coverlet.collector" Version="1.2.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Selenium.Chrome.WebDriver" Version="79.0.0" />
<PackageReference Include="Selenium.WebDriver" Version="3.141.0" />
</ItemGroup>

View File

@ -23,6 +23,10 @@
<ItemGroup>
<PackageReference Include="Autofac" Version="5.1.2" />
<PackageReference Include="coverlet.msbuild" Version="2.8.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="FluentAssertions" Version="5.10.2" />
<PackageReference Include="Microsoft.AspNetCore.DataProtection" Version="3.1.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />