How do I exclude types and methods from being covered by dotCover in TeamCity?

家住魔仙堡 提交于 2019-11-29 19:50:13

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 dotCover Tips & Tricks 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.

This is what the TeamCity docs says about the filter options:

Specify assemblies to profile one per line using following syntax: +:myassembly=;type=;method=*

Use -:myassembly to exclude an assembly from code coverage. Asterisk wildcard (*) is supported here.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!