-
Notifications
You must be signed in to change notification settings - Fork 388
Add support for exclude by attribute #232
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
Comments
Hi @nordinrahman, I'm inclined to agree with you on this. Will add it to my personal backlog but I'm open to PRs on this |
I can start taking a stab at this if no one else is since it also can cover my desire to see |
@nordinrahman if you can, please try to clone my PR (#233) and see if it meets your needs, it passed the basic tests but I'm struggling a bit to see good ways to test it while in development. |
@amweiss , yes I reviewed the code, and it looks good to me. Initially, I intend to add more unit test to cover the business logic introduced, but it's kinda of a challenge (eg changes on console app). I'm yet to run the build against sample project, for manual testing - I will update here once I'm done. Thanks, @amweiss . I wonder what @tonerdo 's opinion on this? |
@nordinrahman I agree, I did the minimum unit test to make sure the attribute excluded the code from coverage. I do have a few stylistic and coverage changes I'll send over on a subsequent PR if this one is getting merged. |
Perhaps apparent to other people, but not me, I think it's only going to work as part of a build the way I did it, not in the CLI afterward since it runs at the instrumenter level. So technically it won't meet the needs of this. |
I believe this is working as part of the build tasks now, @nordinrahman and @tonerdo is there anything left needed to merge #233 ? |
feat: Add ExcludeByAttribute option (#232)
@nordinrahman @amweiss fix is available in latest NuGet releases |
Can we exclude Startup.cs or Program.cs using ExcludeFromCodeCoverage attribute? |
@sbansal-mdsol you could try with https://github.com/tonerdo/coverlet#source-files-1 |
ExcludeFromCodeCoverage is also separate from this, that part worked fine already. This pull request allows for defining arbitrary attributes to ignore as well as ExcludeFromCodeCoverage. |
As of now, coverlet could exclude any classes/methods/properties decorated with ExcludeFromCodeCoverage attribute. However, it does not applicable for code annotated by other attributes like GeneratedCodeAttribute nor CompilerGeneratedAttribute. In short, it does not allow user to exclude with arbitrary attribute. This is one of most common feature for other coverage tool (e.g. dotcover) that I usually use.
There are already demands to this feature, as listed below:
The feature will have the following criteria:
--exclude-by-attribute
for CLI toolExcludeByAttribute
ExcludeByCodeCoverage
remains as is,
, just like existingExclude
list.ExcludeByCodeCoverage
works.TQ.
The text was updated successfully, but these errors were encountered: