PartCover Rules, Methods, and Lambda Expressions

PartCover has a rule system to dictate what classes you want to see code-coverage reports for. Filters take the format of:

plus or minus[project]namespace filter
“plus or minus” is + (which means: show code-coverage for this rule) or – (which means: don’t show code coverage for this rule).

“project” (enshrined in square brackets) is the name of the project which you’re testing. If you have, for example, one application with multiple projects, you can put the project name here. It can take * as a wildcard.

“namespace filter” is a fully-qualified namespace filter. For example, say you have the following namespaces:


com.csharpcity.utils.persistence.post
com.csharpcity.utils.persistence
com.csharpcity.utils.collections
com.csharpcity.core.model.post
com.csharpcity.core.model.comment

You could match the first two with the namespace filter com.sharpcity.utils*; or you can match any of the post-related namespace filters with *post.

This might seem trivial, but you can’t add rules for methods. This means that if you have delegate classes–great, they’re excludable! But if you have just simple getters and setters, you’re stuck with writing tests for them.

Also, be aware that using lambda expressions creates new classes with names similar to __DisplayClass*. This is because lambda expressions are really delegate classes under the hood.

About Ashiq Alibhai, PMP

Ashiq has been coding C# since 2005. A desktop, web, and RIA application developer, he's touched ASP.NET MVC, ActiveRecord, Silverlight, NUnit, and all kinds of exciting .NET technologies. He started C# City in order to accelerate his .NET learning.
This entry was posted in Tools, Wndows Forms and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *