xaberue
xaberue

Reputation: 336

Publish Code Coverage doesn't work in .NET Core Azure pipeline

I am trying to add Code Coverage results in an Azure DevOps build for a .NET Core project, but, trying two different approaches based on this guide on MSDN:

Currently, after building the solution, I have a dotnet step for test, collecting the Code Coverage and publishing those results. I also tryed disabling this check for publishg, and adding a command line step and a Publish Test Results.

Here the screenshot and yaml for the test step:

Test step

- task: DotNetCoreCLI@2
  displayName: 'Test solution'
  inputs:
    command: test
    projects: '**/*Test/*.csproj'
    arguments: '--configuration $(buildConfiguration) --collect "Code coverage"'
    workingDirectory: ChustaSoft.Common.UnitTest

And here the screenshots and yaml for the currently disabled steps:

Command line script

- script: 'dotnet test ChustaSoft.Common.UnitTest --logger trx --collect "Code coverage"'
  displayName: 'Command Line Script'
  enabled: false

Publish test result step

- task: PublishTestResults@2
  displayName: 'Publish Test Results'
  inputs:
    testResultsFormat: VSTest
    testResultsFiles: '**/*.trx'
  enabled: false

With both approaches, I could see Test results, but not the Code Coverage, here is an screenshot of what I am able to see it:

Build summary Test results

Any idea? I am missing something? How can I see the Code Coverage when the build is finished?

Thank you a lot in advance,

PD: Project is multitarget: .NET Core 2.0, .NET Standard 2.0 and .NET 4.6.1, UnitTest project is a .NET Core MSTest project

EDIT: Added Test step output: Test output

Upvotes: 1

Views: 1863

Answers (1)

Kos
Kos

Reputation: 567

Try to run the tests with adding first

Visual Studio Test Platform Installer Task

then

Visual Studio Test -->>Test assemblies Task

Remove the Publish Test and the Command line Tasks.

Upvotes: 1

Related Questions