How do I exclude types and methods from being covered by dotCover in TeamCity?
Ok, Martin, I figured it out! It only took an hour of randomly poking at the filter syntax... when the documentation says to add a filter like this
+:myassembly=*;type=*;method=***
They really mean this... where anything in <>
is replaced entirely by you and anything else is a literal
+:<myassembly>;type=<filter>;method=<filter>
So, the filter I wanted was to include a single assembly (from a bunch of assemblies) and then exclude a few namespaces in that assembly. I wrote
+:Omnyx.Scanner
-:Omnyx.Scanner;type=Omnyx.Scanner.Simulation.*
-:Omnyx.Scanner;type=Omnyx.Scanner.ToolsCommon.*
Take a look at the Coverage Analysis from the Command Line - Applying filters page. It looks like you can set up exclusions in the Filters section, similar to how you excluded entire assemblies.
Let's say you want to ignore a method called DoStuff
contained in a class MyStuff
, which is in the MyAwesomeAssembly
library. Then your dotCover XML should look something like this:
<Filters>
<ExcludeFilters>
<FilterEntry>
<ModuleMask>MyAwesomeAssembly</ModuleMask>
<ClassMask>MyStuff</ClassMask>
<FunctionMask>DoStuff</FunctionMask>
</FilterEntry>
</ExcludeFilters>
</Filters>
Disclaimer: I don't use dotCover, so I'm not 100% sure if this will actually work.