Run tests from your TFS Team Build without a test list (.vsmdi) with code coverage

I got around to trying Buck Hodges' power toy that lets you run unit tests in your Team Foundation Server (TFS) Team Build without having to use a test list (aka “.vsmdi” file). 

It works well but getting code coverage to run with it was kind of a trick.  There's a post on forums.microsoft.com that discusses how to do it but -- uhhh -- it's kind of hard to understand and -- uhhh -- didn't work (exactly).  (The installation instructions for the power toy itself was super easy).

Here's the process for getting it all working with code coverage.

Download the power toy zip and extract the contents to a directory on your Team Build Server.

Copy “Microsoft.TeamFoundation.PowerToys.Tasks.QualityTools.dll“ to “C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies\“.

Copy "Microsoft.TeamFoundation.Build.targets" to "C:\Program files\MsBuild\Microsoft\VisualStudio\v8.0\TeamBuild".

Let's assume that you have an existing Team Build (MSBuild) script you're using to run a test list.  Open up the build script (TFSBuild.proj) and find the section that looks like this:

Change that section so that it looks like this:

The important part here is removing the “MetaDataFile“ block and adding the “TestContainerInOutput” block.  (I removed the extra code comments, too but this is optional.)

Ok.  This takes case of getting the unit tests executing.  Now we need to add support for code coverage.  Since code coverage is configured in a testrunconfig file, we need need to tell the msbuild/test engine which testrunconfig to load and where to get it (the file's path).

Go back to the top of your MSBuild script and find the first “PropertyGroup” element.  It'll probably start something like this:

Find the end of the PropertyGroup tag and add a reference to your testrunconfig before the closing “PropertyGroup“ tag:

Save your build script, check it in, and re-run your Team Build.  You should now be getting unit test and code coverage data without having to use a .vsmdi test list. 

-Ben

posted @ Friday, February 09, 2007 10:45 AM

Print

Comments on this entry:

# How to enable code coverage without a test list

Left by Buck Hodges at 7/5/2007 9:14 PM
Gravatar
Aaron pointed out this post by Ben Day that talks about using the RunConfigFile property with a build

# Improper display of your blog in IE6

Left by Spencer Day at 8/6/2007 4:43 PM
Gravatar
Heads up. I cannot read the right-hand panel of content in your blog, at least here at the bank using our standard IE6 configuration (IE7 coming soon, I am told) - which is the same on all 200.00+ PCs here. Firefox works fine, though. Being a MSFT guru and all, you may want to pay attention to this detail.
your big fan, Uncle S

# re: Run tests from your TFS Team Build without a test list (.vsmdi) with code coverage

Left by Dmytro Lapshyn at 10/10/2007 4:03 AM
Gravatar
Thanks so much for the detailed workaround description! Since you're an MVP, would you consider re-posting this as a community content in Microsoft's Knowledge Base? I believe this is quite an important workaround so it definitely belongs in there.

# Free xxx pics.

Left by Free xxx galleries. at 1/11/2009 7:56 AM
Gravatar
Xxx free videos. Free xxx chat rooms. Free asian xxx. Free xxx. Free sample xxx. Free xxx movies. Free xxx clips. Xxx free video clips.

# 

Left by MCD Software Solutions blog at 6/10/2009 5:35 AM
Gravatar
IAF open issues solutions

Your comment:



 (will not be displayed)


 
 
 
Please add 4 and 7 and type the answer here:
 

Live Comment Preview:

 
«July»
SunMonTueWedThuFriSat
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678