Azure Pipelines - VSTest@2 生成的 CodeCoverage 在哪里?

ske*_*ske 10 yaml code-coverage vstest azure-pipelines

我已经尝试了数百次,但仍然无法找到 VSTest 任务中生成的 codeCoverage 文件。

请参阅以下代码。

我只想将代码覆盖率报告发布到管道。

请帮助!

代码覆盖率文件在哪里?

或者,如果您不想浪费时间写一些答案,请给我一些链接。

非常感谢!

# ASP.NET
# Build and test ASP.NET projects.
# Add steps that publish symbols, save build artifacts, deploy, and more:
# https://learn.microsoft.com/azure/devops/pipelines/apps/aspnet/build-aspnet-4

trigger:
  - master

jobs:
  - job: devbuild
    pool:
      name: 'Self Hosted VS2017'

    variables:
      solution: '**/*.sln'

    steps:
      - task: NuGetToolInstaller@0

      - task: NuGetCommand@2
        inputs:
          restoreSolution: '$(solution)'

      - task: VSBuild@1
        inputs:
          solution: '$(solution)'
          msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:Configuration=Debug /p:Platform="Any CPU" /p:OutDir=".\output\dev"'
          clean: true

      - task: VisualStudioTestPlatformInstaller@1
        inputs:
          packageFeedSelector: 'nugetOrg'
          versionSelector: 'latestPreRelease'

      - task: VSTest@2
        inputs:
          testSelector: 'testAssemblies'
          testAssemblyVer2: |
            **\dev\*.Tests.dll
          searchFolder: '$(System.DefaultWorkingDirectory)'
****************************************************************************
************THIS GUY  =>****************************************************
          codeCoverageEnabled: true
**********************<=****************************************************
****************************************************************************
          distributionBatchType: 'basedOnAssembly'
          dontDistribute: false
          publishRunAttachments: true

      - task: PublishCodeCoverageResults@1
        inputs:
          codeCoverageTool: 'cobertura'
          summaryFileLocation: '**/coverage.xml'
          reportDirectory: '**/coveragereport'
          failIfCoverageEmpty: true

Run Code Online (Sandbox Code Playgroud)

我想要这个,图片来自网络

Hen*_*ons 17

这对我有用。我必须告诉 vstest 以 Cobertura 格式输出,然后手动发布覆盖率结果:

- task: VSTest@2
  inputs:
    testSelector: 'testAssemblies'
    testAssemblyVer2: |
      **\*Tests.dll
      !**\*TestAdapter.dll
      !**\obj\**
    searchFolder: '$(System.DefaultWorkingDirectory)'
    resultsFolder: '$(build.ArtifactStagingDirectory)/Test/Results'
    otherConsoleOptions: '/collect:"Code Coverage;Format=Cobertura"'  # <<<< this is the important bit
    codeCoverageEnabled: True

# vv Then add publish coverage manually vv
- task: PublishCodeCoverageResults@1
  inputs:
    codeCoverageTool: 'Cobertura'
    summaryFileLocation: '$(build.ArtifactStagingDirectory)/Test/Results/**/*.xml'
Run Code Online (Sandbox Code Playgroud)

然后我在 DevOps 的覆盖率选项卡中得到了漂亮的 HTML 输出


小智 5

尝试添加resultsFolder参数来控制文件位置

# Ejecucion de los Test
- task: VSTest@2
  displayName: 'Ejecucion de los Test'
  inputs:
    testSelector: 'testAssemblies' # Options: testAssemblies, testPlan, testRun
    testAssemblyVer2: | # Required when testSelector == TestAssemblies
      **\*.Test.dll
    searchFolder: '$(Build.SourcesDirectory)\Test' 
    vsTestVersion: '15.0'
    platform: 'x86' # Optional
    codeCoverageEnabled: true
    resultsFolder: '$(build.ArtifactStagingDirectory)\Test\Results'
Run Code Online (Sandbox Code Playgroud)


sta*_*SFT 3

将system.debug变量设置为true,然后队列构建,您可以找到覆盖率文件的整个路径(在日志中搜索覆盖率)

默认情况下,覆盖率文件的名称为xx.coverage

  • system.debug 在哪里?!!!?!?!?!?!?!?!?!?!?!?!?!!!?!?!?!什么是系统调试??????系统调试是谁??? (2认同)