Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I've got an existing C# 4 project which I've checked the test coverage for by using TestDriven.Net and the Visual Studio coverage feature, i.e. Test With -> Coverage from the context menu.

The project contains some code I don't want covered, and I've solved that by adding the [ExcludeFromCodeCoverage] for those types and methods.

We've just upgraded TeamCity to 6.0.3, and I've added dotCover coverage to the NUnit build step.

I've managed to remove coverage for external assemblies such as NHibernate in the "Filters" section (by explicitly state the assemblies for which I want coverage), but I'm struggling with how to exclude types and methods from covered assemblies.

enter image description here

like image 333
Martin R-L Avatar asked Apr 12 '11 07:04

Martin R-L


1 Answers

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.* 
like image 79
Anthony Mastrean Avatar answered Sep 16 '22 17:09

Anthony Mastrean