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.

Update documentation for excluding source files from code coverage

See original GitHub issue

I have problems with excluding source files from code coverage.

Here is my file structure: App.UnitTests – runsettings.xml, <other irrelavant files> App – obj, < project files >

I want to exclude from code coverage the obj folder which is located inside the App folder. So I have navigated in the terminal to App.UnitTests folder and executed this command:

dotnet test --collect:"XPlat Code Coverage" --settings runsettings.xml

Here is my runsettings.xml file.

<?xml version="1.0" encoding="utf-8" ?>
<RunSettings>
  <DataCollectionRunSettings>
    <DataCollectors>
      <DataCollector friendlyName="XPlat code coverage">
        <Configuration>
          <Format>cobertura</Format>
          <ExcludeByFile>../obj/**/*,</ExcludeByFile>
        </Configuration>
      </DataCollector>
    </DataCollectors>
  </DataCollectionRunSettings>
</RunSettings>

Unfortunately this is not working. The code coverage is including files in obj folder. Why is this happening? I will be glad for any help.

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
Mikilll94commented, May 3, 2020

@MarcoRossignoli Ok. Thanks for the response. Yeah, the docs need to be updated because they are very misleading, i.e. here:

https://github.com/tonerdo/coverlet/blob/master/Documentation/VSTestIntegration.md https://github.com/tonerdo/coverlet/blob/master/Documentation/MSBuildIntegration.md#excluding-from-coverage

And the docs even explicitly says:

Use absolute or relative paths (relative to the project directory)

So since the relative path is not working, right now I am using this filter:

**/obj/**/*

This filter excludes all files in the obj folder from code coverage.

0reactions
MarcoRossignolicommented, May 3, 2020

I’ll keep this open until doc fix. There was a bug in first implementation, we fixed code but not documentation 🤔

Read more comments on GitHub >

github_iconTop Results From Across the Web

Customizing Code Coverage Analysis - Visual Studio
You can include or exclude assemblies or specific types and members from code coverage analysis. If the Include section is empty or omitted, ......
Read more >
python - coverage.py: exclude files
According to the documentation you can exclude code by matching lines. I want to exclude entire files, so that the reports don't include...
Read more >
Excluding Files and Folders
To exclude files from test coverage reporting, you'll need to exclude them via your local test coverage suite. Pattern Format. Each entry in...
Read more >
How to Use a File to Exclude Files From Code Coverage
How to Use a File to Exclude Files From Code Coverage · You can set coverage exclusions in the SonarCloud UI. · You...
Read more >
Excluding files from code coverage in GO
First things first, a quick recap. Code coverage can be generated using the go cover tool. From the docs, usage of the tool...
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