Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 12 additions & 15 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,38 +36,35 @@ steps:

# Run all tests with "/p:CollectCoverage=true /p:CoverletOutputFormat=cobertura" to generate the code coverage file
- task: DotNetCoreCLI@2
displayName: Test
displayName: dotnet test
inputs:
command: test
arguments: '--configuration $(BuildConfiguration) /p:CollectCoverage=true --collect:"XPlat Code Coverage"'
arguments: '--configuration $(BuildConfiguration) --logger trx --collect:"XPlat Code Coverage"'
projects: '$(solution)'
nobuild: true
publishTestResults: false
continueOnError: true

# Generate the report using ReportGenerator (https://github.com/danielpalme/ReportGenerator)
# First install the tool on the machine, then run it
- script: |
dotnet tool install -g dotnet-reportgenerator-globaltool
reportgenerator -reports:$(Agent.TempDirectory)/**/coverage.cobertura.xml -targetdir:$(Build.SourcesDirectory)/CodeCoverage -reporttypes:Cobertura
displayName: Create Code coverage report
- task: reportgenerator@4
inputs:
reports: '$(Build.SourcesDirectory)/**/coverage.cobertura.xml'
targetdir: 'coveragereport'
sourcedirs: '$(Build.SourcesDirectory)'

# Publish the code coverage result (summary and web site)
# The summary allows to view the coverage percentage in the summary tab
# The web site allows to view which lines are covered directly in Azure Pipeline
- task: PublishCodeCoverageResults@1
displayName: 'Publish code coverage'
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(Build.SourcesDirectory)/CodeCoverage/Cobertura.xml'
pathToSources: '$(Build.SourcesDirectory)'
summaryFileLocation: '$(Build.SourcesDirectory)/coveragereport/Cobertura.xml'
reportDirectory: '$(Build.SourcesDirectory)/coveragereport'

- task: PublishTestResults@2
inputs:
testResultsFormat: 'VSTest'
testResultsFiles: '$(Agent.TempDirectory)/**/coverage.cobertura.xml'
testResultsFiles: '**/*.trx'
mergeTestResults: true
failTaskOnFailedTests: true

- task: DotNetCoreCLI@2
inputs:
command: publish
Expand Down