如何使用 yml 将 nunit 单元测试项目的代码覆盖率包含在 coverlet 和 covertura configin azure 管道中

问题描述 投票:0回答:1

我正在尝试获取解决方案的 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'
asp.net-core azure-pipelines code-coverage cobertura coverlet
1个回答
0
投票

尝试在

>
任务的
|
属性中使用多行字符串指示符
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'

Image

Image

© www.soinside.com 2019 - 2024. All rights reserved.