Skip to content

StefH/CoverageConverter

Repository files navigation

dotnet-coverageconverter

Convert .coverage (binary format) files to .coveragexml (xml format) files to support SonarCloud Code Coverage when using VSTest@2.

NuGet Badgedotnet-coverageconverter

Installation

Install locally:

dotnet tool install --global dotnet-coverageconverter

or

Install the tool in your yml pipeline:

- task: DotNetCoreCLI@2
  displayName: "Install tool: dotnet-coverageconverter"
  inputs:
    command: 'custom'
    custom: 'tool'
    arguments: 'update --global dotnet-coverageconverter'

Usage

  • Step 1: Define a VSTest@2 task with codeCoverageEnabled: true
  • Step 2: Define a CmdLine@2 task with the dotnet-coverageconverter-tool and provide the CoverageFilesFolder where the .coverage files are placed by vstest.console.exe

Example YML pipeline tasks

- task: VSTest@2
  displayName: 'VsTest'
  inputs:
    testSelector: 'testAssemblies'
    vsTestVersion: 16.0
    diagnosticsEnabled: true
    codeCoverageEnabled: true
    testAssemblyVer2: |
     **\*tests.dll
     !**\*UITests.dll
     !**\*TestAdapter.dll
     !**\obj\**

- task: CmdLine@2
  displayName: 'Convert .coverage to .coveragexml'
  inputs:
    script: 'dotnet-coverageconverter --CoverageFilesFolder "$(Agent.TempDirectory)\TestResults"'

Commandline Options

  -f, --CoverageFilesFolder            Required. The folder where the .coverage files are defined.

  -d, --DotCoverageExtension           (Default: .coverage) The extension from the coverage files.

  -a, --AllDirectories                 (Default: true) Includes also sub-folders in the search operation.

  -p, --ProcessAllFiles                (Default: false) Process all .coverage files, if not set, then only folders which are a guid (that's the one VSTest creates) will be processed.

  -o, --Overwrite                      (Default: true) Overwrite the existing .coveragexml files.

  -r, --RemoveOriginalCoverageFiles    Remove the original .coverage files.

  --help                               Display this help screen.

  --version                            Display version information.

Info

This project is inspired by Visual-Studio-Coverage-Tools.

About

Convert .coverage files (binary format) to .coveragexml (xml format) files to support SonarCloud code-coverage when using VSTest@2

Resources

License

Stars

Watchers

Forks

Packages

No packages published