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

Adding a Filter property to include/exclude assemblies/types #77

Closed
MarcoRossignoli opened this issue May 3, 2018 · 4 comments
Closed

Comments

@MarcoRossignoli
Copy link
Collaborator

MarcoRossignoli commented May 3, 2018

Rationale

Coverlet currently allow to ignore methods/classes using attribute or specific source files using /p:Exclude property.

It would be useful filter(include/exclude) assembly/types in a "similar" way of popular OpenCovers framework.

Proposal

Some examples

To Include assembly but exclude all classes of particular namespace.

dotnet test /p:CollectCoverage=true /p:Filter="+[AssemblyName] -[AssemblyName]Namespace.*"

To include only one class

dotnet test /p:CollectCoverage=true /p:Filter="+[AssemblyName]Namespace.ClassName"

To include all classes ends with "ClassNameSuffix" of AssemblyName

dotnet test /p:CollectCoverage=true /p:Filter="+[AssemblyName]*ClassNameSuffix"

Details

Filters can be inclusive and exclusive represented by + and – prefix respectively, where exclusive (-) filters take precedence over inclusive (+) filters.
Assembly here is like a module, 99.9% we have a single file assembly.

Open Questions

  • Add also /Include=[*]*, does it make sense?

cc: @tonerdo @abe545 @ido-namely @ryanmvt @coenm @mathnogueira

@MarcoRossignoli
Copy link
Collaborator Author

MarcoRossignoli commented May 3, 2018

I'll keep proposal updated with our discussion!

@MarcoRossignoli MarcoRossignoli changed the title Adding a Filter property to exclude assemblies/types Adding a Filter property to include/exclude assemblies/types May 3, 2018
@tonerdo
Copy link
Collaborator

tonerdo commented May 11, 2018

I intend to look into this over the weekend

@MarcoRossignoli
Copy link
Collaborator Author

MarcoRossignoli commented May 14, 2018

I'm thinking maybe we could have also an /Include= and say that default for coverlet if attributes are missing is /Include=[*]* this could address one of my coverage scenario where i need to be sure that only 2/3 of my tens classes are covered for > 95% or fail! This may appear strange but in my scenario i "host" these classes in some "environment hosts" and i don't need to be sure that all are "well covered", but would be great if i could "enforce" my devs to cover well what i think is very important. What do you think?

If you are not convinced i could take some time and try an "explorative PR".

@tonerdo again thank's a lot for PR!

@tonerdo
Copy link
Collaborator

tonerdo commented May 17, 2018

#94 merged in an released https://www.nuget.org/packages/coverlet.msbuild/2.0.0. Thanks for your patience guys

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants