19

How can I add filters to skip some of the classes in a namespace/assembly. For example: SYM.UI is the base assembly and i want to skip SYM.UI.ViewModels. Writing the below filter but it is including all of them and not fulfilling my request:

+[SYM.UI*]* -[SYM.UI.ViewModels*]*

Kindly help me correcting this?

johnnyRose
  • 7,310
  • 17
  • 40
  • 61
Ravindra
  • 191
  • 1
  • 1
  • 3
  • i have tried using like below +[SYM.UI*]* -[SYM.UI]ViewModels* but still no luck. advise – Ravindra Jul 27 '11 at 04:59
  • adding for future readers: You should have an explicit filter "+[ * ]*" always present as a catchall, for case of **providing only exclusion list in filter**. If you are not providing "+[ * ]*" for this case then no code coverage report will be generated. – Devesh Mar 28 '16 at 13:06

2 Answers2

28

The opencover wiki is a good place to start.

The usage is described as +/-[modulefilter]typefilter (this is based on how you would see the types in IL; where the type filter also includes the namespace and module filter usually is the name of the assembly (without the file extension).

Thus to exclude your types you could use

+[SYM.UI]* -[SYM.UI]SYM.UI.ViewModels.*

NOTE: Exclusion filters take preference over inclusion filters.

cederlof
  • 7,206
  • 4
  • 45
  • 62
Shaun Wilde
  • 8,228
  • 4
  • 36
  • 56
  • 3
    There is also some packaged documentation with OpenCover which is worth a read as it is more up to date than the wiki (I am not a wiki person) – Shaun Wilde Aug 02 '12 at 22:42
4

You can use following:

"-filter:+[*]* -[SYM.UI]SYM.UI.ViewModels.*"

Note that the quotes must be around the -filter: part, too

thomasb
  • 5,816
  • 10
  • 57
  • 92
Sumit Gupta
  • 775
  • 7
  • 9