I have tried to create a code coverage for my webapi. I have followed this link.
I have changed the YML file and got the below build failed error in Azure Devops.
I have used the following code for this. How to fix this?
steps:
- task: DotNetCoreCLI@2
displayName: 'Build project'
inputs:
projects: '**/*.csproj'
arguments: '--output $(Build.BinariesDirectory) --configuration Release'
- task: DotNetCoreCLI@2
displayName: 'Install .NET Core tools from local manifest'
inputs:
command: custom
custom: tool
arguments: 'restore'
- task: VSTest@2
displayName: 'Unit Tests'
inputs:
testSelector: 'testAssemblies'
testAssemblyVer2: |
**\*Tests*.dll
!**\*TestAdapter.dll
!**\obj\**
searchFolder: '$(Build.BinariesDirectory)'
arguments: '--no-build --configuration $(buildConfiguration) /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CoverletOutput=$(Build.BinariesDirectory)/TestResults/Coverage/'
publishTestResults: true
projects: '**/*.Tests.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'
