我正在尝试获取解决方案的 azure pepeline 中的代码覆盖率,其中也应包括我的 nunit 测试项目的代码覆盖率。然而,我的 yml 更改在下面不起作用。
# 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'
尝试在
>
任务的 |
属性中使用多行字符串指示符 arguments
代替 DotNetCoreCLI@2
。
variables:
sytem.debug: true
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: DotNetCoreCLI@2
displayName: 'Run Tests'
inputs:
command: 'test'
projects: '**/*.csproj'
arguments: >
--configuration $(buildConfiguration)
--collect:"XPlat Code Coverage"
--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'