Getting PartCover to work

sgwill picture sgwill · Dec 12, 2008 · Viewed 15.4k times · Source

I want to try PartCover for code coverage. I'm running Visual Studio 2008 Professional with MSTest. The Professional Edition does not include the Team Testing tools, like Code Coverage.

So, I'm trying PartCover, but I can't get it to work. In the PartCover.Browser I've selected the MSTest executable, I've pointed the working arguments to my tests.dll, and I've tried pointing my Working Directory to the TestResults folder, but I get an error:

"Report is empty. Check settings and run target again."

I don't know what to try next.

Edit

It turns out I had two problems. First, I wasn't putting my Rules right. Second, I had spaces in my working arguments. The spaces were giving an error, but not showing up anywhere.

Answer

Hamish Smith picture Hamish Smith · Dec 12, 2008

Yep, I had this problem too. Check out the format for the Rules field.

In the browser add something like:

+[MyNamespace.MyAssemblyName]*

Where the assembly name you specify is the name of the assembly containing the types you want coverage for. Start off with:

+[*]*

and partcover will happily give you coverage metrics for the unit test project, any libraries you reference and on and on.

From the command line you specify the same pattern in the --include argument: --include=[MyNamespace.MyAssembly]*

You can also exclude contained namespaces or types or restrict which types from within the namespace you get coverage data for in the report. The format for the rules is a subset of regular expression syntax according to the manual (consisting of asterix as a wildcard and characters that make up assembly and class names, so pretty limited but enough to get the data you want). Check out the section on rules in the manual. If you don't have the manual, download it from sourceforge.