0
votes

I follow the steps of Computing code coverage for a .NET Core project with Azure DevOps and Coverlet.

Build run like expected and every step ends successfully.

Build results

The Artefact-Explorer shown the uploaded report and In summary I get the Code Coverage result.

CodeCoverage result

But I missing the Code Coverage tab next to Tests tab to take a look to the detailed report.

Configuration YAML:

- task: NuGetToolInstaller@0

  displayName: 'Use NuGet 5.0.2'

  inputs:

    versionSpec: 5.0.2
    checkLatest: true


- task: NuGetCommand@2

  displayName: 'NuGet restore'

  inputs:

    restoreSolution: '$(Parameters.solution)'


- task: VSBuild@1

  displayName: 'Projektmappe **\*.sln erstellen'

  inputs:

    solution: '$(Parameters.solution)'  
    platform: '$(BuildPlatform)'
    configuration: '$(BuildConfiguration)'


- task: VisualStudioTestPlatformInstaller@1

  displayName: 'Installer für Visual Studio Test-Plattform'
  enabled: false



- task: VSTest@2

  displayName: 'VsTest - testAssemblies'

  inputs:

    testAssemblyVer2: |
     **\$(BuildConfiguration)\*test*.dll
     !**\obj\**

    codeCoverageEnabled: true
    platform: '$(BuildPlatform)'
    configuration: '$(BuildConfiguration)'



- powershell: ./'D:\AzureDevOpsData\Skripte\PowerShell\CodeCoverage.ps1'

  displayName: 'PowerShell Test Code Coverage'



- task: Palmmedia.reportgenerator.reportgenerator-build-release-task.reportgenerator@4

  displayName: ReportGenerator

  inputs:

    reports: coverage.cobertura.xml
    targetdir: '$(Build.SourcesDirectory)/CodeCoverage'



- task: PublishCodeCoverageResults@1

  displayName: 'Code Coverage veröffentlichen von $(Build.SourcesDirectory)/CodeCoverage/Cobertura.xml'

  inputs:

    codeCoverageTool: Cobertura
    summaryFileLocation: '$(Build.SourcesDirectory)/CodeCoverage/Cobertura.xml'
    reportDirectory: '$(Build.SourcesDirectory)/CodeCoverage'

The PowerShell Script contains:

#TEST CSPROJ
$csproj = "FrameworkA_Tests"

#SEARCH TEST CSPROJ.DLL
"`nrun tests:"
$unitTestFile = gci -Recurse | ?{ $_.FullName -like "*bin\*$csproj.dll" }
Write-Host "`$unitTestFile value: $unitTestFile"

#GET COVERLET.EXE
$coverlet = "D:\AzureDevOpsData\Tools\coverlet\coverlet.exe"

#RUN COVERLET.EXE
"calling $coverlet for $($unitTestFile.FullName)"
&$coverlet $unitTestFile.FullName --target "dotnet" --targetargs "vstest $($unitTestFile.FullName) --logger:trx" --format "cobertura"

Do I forget something?

2

2 Answers

0
votes

ReportGenerator missing Code Coverage tab (Azure DevOps Server 2019.0.1)

This should be a known issue on the Developer Community:

Code coverage tab missing in Azure DevOps Server

MS team reply: A fix for this issue has been internally implemented and is being prepared for release.

As workaround, you can try the method provided by jingzhu yan:

you can add copy files and publish build results steps , then you can download coverage result file from Artifacts.

enter image description here

enter image description here

Hope this helps.