Reputation: 125
I have 3 projects in my solution including the test project. I get only 2 project in code coverage result in the azure pipeline which excludes the test project. I want to include the test project also in the code coverage.I am trying to get the code coverage in the azure pipeline for the solution which should include the code coverage for my nunit test project also. However it's not working below is my yml change.
# Run tests with Coverlet code coverage and include the test project in coverage results
- task: DotNetCoreCLI@2
displayName: 'Run Tests'
inputs:
command: 'test'
projects: '**/Warsy.Fulto.Test.csproj'
arguments: |
--configuration $(buildConfiguration)
--collect:"XPlat Code Coverage"
/p:Include="[Warsy.Fulto.Test]*"
--verbosity detailed
# Publish code coverage results
- task: PublishCodeCoverageResults@2
displayName: 'Publish CodeCoverage'
inputs:
codeCoverageTool: 'Cobertura'
summaryFileLocation: '$(Agent.TempDirectory)/**/coverage.cobertura.xml'
Upvotes: 0
Views: 254
Reputation: 6212
As far as I tested, the |
indicator for the arguments
property of the DotNetCoreCLI@2
task would have the dotnet test
command broken.
You may try with a single-line argument or use the multiline string indicator >
instead of |
in the arguments
property of the DotNetCoreCLI@2
task as in my sample below.
pool:
vmImage: 'windows-latest'
variables:
sytem.debug: true
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: DotNetCoreCLI@2
displayName: 'Build solution'
inputs:
command: 'build'
projects: '$(solution)'
arguments: '--configuration $(buildConfiguration)'
- task: DotNetCoreCLI@2
displayName: 'Run Tests'
inputs:
command: 'test'
projects: '**/AzureWebAppDotNetCore8Tests.csproj'
arguments: >
--no-build
--configuration $(buildConfiguration)
--collect:"XPlat Code Coverage"
/p:Include="[AzureWebAppDotNetCore8.Tests]*"
--verbosity detailed
continueOnError: true
- powershell: tree $(Agent.BuildDirectory) /f /a
displayName: Check test and coverage results
# Publish code coverage results
- task: PublishCodeCoverageResults@2
displayName: 'Publish CodeCoverage'
inputs:
codeCoverageTool: 'Cobertura'
summaryFileLocation: '$(Agent.TempDirectory)/**/coverage.cobertura.xml'
Upvotes: 0