yamlcode-coverageazure-pipelinesvstest

Azure Pipelines - Where is the CodeCoverage generated by VSTest@2?


I have tried hundreds of times but I am still unable to find that codeCoverage file generated in VSTest task.

See the following code.

I simply want to publish the Code Coverage report to the pipeline.

Help, please!

Where is that code coverage file?

Or give me some links if you don't want to waste time writing some answers.

Many thanks!

# 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

I want this, image grabbed from internet


Solution

  • Set system.debug variable to true, then queue build, you can find the whole path of coverage files (search coverage in log)

    By default, the coverage file's name is xx.coverage.