-
Notifications
You must be signed in to change notification settings - Fork 11
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to ExcludeFromCodeCoverageAttribute in a test framework scenario? #12
Comments
|
Note: Brad Wilson, xunit maintainer, said this is not a real concern for him, since xunit does not collect code coverage stats for the project today. However, I am curious what the VSTest engineers have to say about this base case. |
|
cc: @jakubch1 |
|
Thanks for the report. We will work on excluding xunit dlls by default. |
|
Oops. Hit close by accident while holding my newborn. Just wanted to say that you should also think about Coverlet approach ExcludeByAttribute. For example, what about assertion libraries like Shoudly. |
|
In latest version https://dev.azure.com/dnceng/public/_artifacts/feed/test-tools/NuGet/Microsoft.CodeCoverage/overview/17.7.0-preview.23203.7 we added default exclusion of few libraries. We are working on some more generic approach like Coverlet has so not closing this. |
Hi @jakubch1 , what does this approach consist of? Can you share some information about it? It would be nice to exclude from code coverage report all about third-party libraries (without using .runsettings files) |
|
We added some default exclusions for xunit and moq libraries. Generic solution is still not implemented. |
|
I think this is related to #72 |
|
In latest version https://dev.azure.com/dnceng/public/_artifacts/feed/test-tools/NuGet/Microsoft.CodeCoverage/overview/17.10.0-preview-24073-02 we ported from Coverlet feature to optionally exclude modules based on existence of sources. To enable this feature in command line you can use: If you use config/runsettings you can add: under Remember that this is adding additional processing to check existence of sources. You will get always better performance by configuring correctly |
|
Shouldn't this be the default? |
|
I don't want to make it default because of performance. To check if sources exist you need to start with dll path => read dll metadata => read PDB data and get all sources => in case of deterministic build calculate original paths => check each file existence. This can take time for big solutions For To calculate coverage using our tooling, sources are not needed so you can imagine scenarios that you build test projects on 1 machine then move binaries to several test nodes and execute them there. We are able to collect coverage in such scenarios. |

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.

Description
If I run
dotnet test --collect="Code Coverage", then it counts xunit classes towards code coverage statistics.Coverlet addresses this problem by providing an ExcludeByAttribute where the user can define arbitrary attributes to use for exclusion purposes.
Steps to reproduce
dotnet test --collect="Code Coverage"Expected behavior
xunit assemblies not included in code coverage report.
Actual behavior
xunit assemblies included in code coverage report.
Diagnostic logs
n/a - please specify what you would want for this, and I can provide
Environment
Test SDK 17.5
The text was updated successfully, but these errors were encountered: