question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Code coverage exclude: local OK, Azure DevOps => not OK

See original GitHub issue

Hi,

I am writing a .NET Core 3.1 web api and have a unit test project to run my unit test. Everything is being done in Visual Studio Professional 2019 (latest update).

In my unit test project (xUnit) I have following references to have coverlet working

<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
    <PackageReference Include="coverlet.msbuild" Version="2.9.0">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.TestPlatform.ObjectModel" Version="16.6.1" />

When I run locally, my excludes do work (I want to exclude everything with Models in the namespace) dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CoverletOutput=./MyCoverage/ /p:Exclude="[*]*.Models*"

image

Now, when I include it in my build pipeline, with following step (and of course a step publishing it as well)

- task: DotNetCoreCLI@2
  displayName: Run unit tests
  inputs:
    command: test
    projects: '**/*Test/*.csproj'
    arguments: '/p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CoverletOutput=./MyCoverage/ /p:Exclude="[*]*.Models*"'
    publishTestResults: true

The coverage is calculated, report is available, but…

image

As you may see, it keeps the coverage on model in the report. Since the commands are the same, I am running out of ideas what the issue is here to be honest 😃 It’s not like I can debug locally, as it works over there 😃

UPDATE: Maybe good to know, the log in the build pipeline reports image Whereas the report itself display for the API.Data project 66.6% line coverage & 70% for branch coverage

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
ranoufcommented, Apr 8, 2022

@MarcoRossignoli Thanks a lot, it works!

1reaction
BloodSeakercommented, Aug 27, 2020

Hi thanks for your quick reply I just did another test and now I noticed something weird

Locally, I am using reportgenerator version 4 something. Azure Devops is loading in a version 1.x 😕 Stupid Azure DevOps. I am manually adding ReportGenerator task now, that should do the trick

Read more comments on GitHub >

github_iconTop Results From Across the Web

Excluding files from code coverage analysis in Azure ...
I want to exclude all 3rd party DLLs like FluentAssertion, Microsoft.Azure etc. Below are the some line from my YAML file which produces...
Read more >
No option to exclude files from code coverage
In VS for Mac (2019 community edition) there is no option to exclude files from code coverage as described in the below link....
Read more >
Configuring CI/CD Pipelines as Code with YAML in Azure ...
Enter a globally unique server name, such as “pul-yaml-johndoe” and provide admin credentials, then click OK. In Database details under ...
Read more >
SonarCloud includes a file for code coverage although it's ...
SonarCloud: ALM used (GitHub) CI system used (Azure DevOps) Error observed - I have excluded a file from being considered in code coverage...
Read more >
exclude section in runsettings file being ignored in azure ...
exclude section in runsettings file is being ignored and all the dlls are being picked in while calculating code coverage through azure pipeline ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found