Skip to content

Instantly share code, notes, and snippets.

@pritpalp
Last active August 19, 2021 14:46
Show Gist options
  • Save pritpalp/ccdb68a940701ef4e0e7f2831e2aeb14 to your computer and use it in GitHub Desktop.
Save pritpalp/ccdb68a940701ef4e0e7f2831e2aeb14 to your computer and use it in GitHub Desktop.
- script: "dotnet add package coverlet.collector"
displayName: 'Install the coverlet collector'
- script: "dotnet tool install dotnet-reportgenerator-globaltool --global"
displayName: 'Install the report generator tool'
- script: dotnet test UnitTests/UnitTests.csproj --logger "trx;LogFileName=testresults.trx" --collect:"XPlat Code Coverage" && reportgenerator "-reports:UnitTests/TestResults/*/coverage.cobertura.xml" "-targetDir:UnitTests/TestResults/Coverage/Reports" -tag:$(Build.BuildNumber) -reportTypes:htmlInline
workingDirectory: UnitTests
displayName: 'Run dotnet test and ReportGenerator on results'
- task: PublishTestResults@2
inputs:
testResultsFormat: 'VSTest'
testResultsFiles: '**/testresults.trx'
searchFolder: 'UnitTests'
failTaskOnFailedTests: true
- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: 'Cobertura'
summaryFileLocation: 'UnitTests/TestResults/*/coverage.cobertura.xml'
reportDirectory: 'UnitTests/TestResults/Coverage/Reports'
failIfCoverageEmpty: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment