Skip to content

Instantly share code, notes, and snippets.

@DanielSSilva
Created July 13, 2021 10:18
Show Gist options
  • Save DanielSSilva/82c9928ef447980e3f10654cecee911a to your computer and use it in GitHub Desktop.
Save DanielSSilva/82c9928ef447980e3f10654cecee911a to your computer and use it in GitHub Desktop.
The tasks to install dependencies, run tests and code coverage
- task: DotNetCoreCLI@2
displayName: 'Install .NET tools from local manifest'
inputs:
command: custom
custom: tool
arguments: 'restore'
- task: DotNetCoreCLI@2
displayName: 'Run unit tests'
inputs:
command: 'test'
arguments: '--no-build --configuration $(buildConfiguration) /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CoverletOutput=$(Build.SourcesDirectory)/TestResults/Coverage/'
publishTestResults: true
projects: GreeterProject/GreeterTests/GreeterTests.csproj
- task: DotNetCoreCLI@2
displayName: 'Create code coverage report'
inputs:
command: custom
custom: tool
arguments: 'run reportgenerator -reports:$(Build.SourcesDirectory)/**/coverage.cobertura.xml -targetdir:$(Build.SourcesDirectory)/CodeCoverage -reporttypes:HtmlInline_AzurePipelines'
- task: PublishCodeCoverageResults@1
displayName: 'Publish code coverage report'
inputs:
codeCoverageTool: 'cobertura'
summaryFileLocation: '$(Build.SourcesDirectory)/**/coverage.cobertura.xml'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment