Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The CoverletOutput property generated report does not use runsettings file exclusions #1695

Closed
fossbrandon opened this issue Sep 3, 2024 · 1 comment
Labels
duplicate This issue or pull request already exists question This issue is a question

Comments

@fossbrandon
Copy link

Describe the bug
While trying to use coverlet to collect code coverage while ignoring certain files specified in my .runsettings file, these exclusions are not honored if I specify a value for the CoverletOutput property.

To Reproduce

  • A test project with a .runsettings file linked in the csproj that excludes some files. Ex: <ExcludeByFile>**/*.sg.cs,</ExcludeByFile>
  • Run the test command and specify the CoverletOutput property. Ex: dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CoverletOutput=TestResults/latest-coverage.xml
  • The command will generate the normal coverage result within a generated GUID subfolder which properly excludes the files specified in the runsettings file. The coverlet output generated file (ex: latest-coverage.xml) will not exclude the same files and produces a different report.

Expected behavior
The output specified in the CoverletOutput property should properly exclude files specified in a runsettings file like the report generated without specifying that value.

Actual behavior
The report generated at the specified value for CoverletOutput produces a report that does not use the runsettings exclusions.

Configuration (please complete the following information):
Please provide more information on your .NET configuration:
* Which coverlet package and version was used?
- coverlet.collect - 6.0.2
- coverlet.msbuild - 6.0.2
* Which version of .NET is the code running on?
- .NET 8
* What OS and version, and what distro if applicable?
- Windows 11 - 10.0.22631 Build 22631
* What is the architecture (x64, x86, ARM, ARM64)?
- X64
* Do you know whether it is specific to that configuration?
- I don't think so

Additional context
If I add the additional property /p:ExcludeByFile=\"**.sg.cs\" it does properly exclude the files I want it to. I would just prefer to exclude in the runsettings file only without having to duplicate them when running the command by hand.

@github-actions github-actions bot added the untriaged To be investigated label Sep 3, 2024
@Bertk Bertk added question This issue is a question and removed untriaged To be investigated labels Sep 5, 2024
@Bertk
Copy link
Collaborator

Bertk commented Sep 5, 2024

Thank you for bringing this up.

The VSTest integration with coverlet.collector uses the .runsettings see VSTestIntegration.md

You are using coverlet.msbuild which only supports MSBuild properties e.g. /p:ExcludeByFile=\"**.sg.cs\"

dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CoverletOutput=TestResults/latest-coverage.xml

@Bertk Bertk closed this as completed Sep 5, 2024
@Bertk Bertk added the duplicate This issue or pull request already exists label Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists question This issue is a question
Projects
None yet
Development

No branches or pull requests

2 participants