Welcome to MSDN Blogs Sign in | Join | Help

How to run tests in a build without test metadata files and test lists (.vsmdi files)

Since the beginning, running tests in Team Build (or MSBuild in general) has meant having to use .vsmdi files to specify the tests to run.  Tons of people have complained about it, as it's a burden to create and edit the files, as either VSTS for Testers or the full suite is required in the 2005 release, and merging changes to the file is painful when multiple developers are updating the file.  While mstest.exe has a /testcontainer option for simply specifying a DLL or load/web test file, the test tools task used with MSBuild does not expose an equivalent property.

Attached to this post is a zip archive containing the files needed to run tests without metadata.  There are three files.

  1. TestToolsTask.doc contains the instructions for installing the new task DLL and modifying the TfsBuild.proj files to use it.
  2. Microsoft.TeamFoundation.Build.targets is a replacement for the v1 file by the same name that resides on the build machine.
  3. Microsoft.TeamFoundation.PowerToy.QualityTools.dll contains the new TestToolsTask class that extends the TestToolsTask class that shipped in v1 and exposes a TestContainers property that is is the equivalent of mstest.exe's /testcontainer option.

After you read the instructions (please, read the instructions), you'll be able to run all of your unit tests by simply specifying the DLLs or even specifying a file name pattern in TfsBuild.proj.  Here are a couple of examples.  The TestToolsTask.doc file explains how they work, including what %2a means.

<TestContainerInOutput Include="HelloWorldTest.dll" />
<TestContainerInOutput Include="%2a%2a\%2aTest.dll" />
<TestContainer Include="$(SolutionRoot)\TestProject\WebTest1.webtest" />

This new task will be included in future releases of the Team Foundation Power Toys (soon to be called Power Tools).  The TestToolsTask in the shipping product will support test containers and Team Build will support using it in the next release of the product.

I started with code and documentation that someone else wrote and finished it off.  Thanks to Clark Sell for digging up an old email thread about the original work and Tom Marsh, development lead in VSTS Test, for pointing me to the code and doc.  Thanks to Aaron Hallberg and Patrick Carnahan, Team Build developers, for their help.  Thanks to Brian Harry for letting me post it.

Please post your feedback in the comments to this post.  We'd like to know if this hits the mark, or if there's something else we need to support.

[UPDATE 4/26/2007] New features: Test categories and test names

Pierre Greborio, a developer over in MSTV, has contributed a great new feature: test categories.  Those of you who have used NUnit are probably familiar with the Category attribute.  Test categories allow you to execute specific groups of unit tests.  Unlike the test container feature, the test category feature will not be in Orcas.

While the details are discussed in the TestToolsTask.doc included in the zip file attached to this blog post, here's the quick version.

  1. Add the Category attribute to your unit test method.
  2. Specify the category to run in your tfsbuild.proj file.

The other feature that's new in this release is the support for test names.  This is equivalent to the mstest.exe /test command line switch.  The name that's specified is implicitly a wildcard match.  Specifying "Blue" as the test name, for example, will execute every test method that has Blue in the name, including DarkBlue and BlueLight.

Pierre did his testing on Vista.  Because the dll is not signed, he ran into some trust issues.  If you hit a similar problem, he recommends this forum post for how to get it to work.

[UPDATE 11/9/2006] Bug fix

I've updated the attachment with a new zip archive file.  Unfortunately, the task I posted originally didn't result in builds being marked as Failed when the tests had errors.  I missed that in my testing.  The reason for the problem is that the v1 Team Build logger looks for the task name, TestToolsTask, and the power toy task was originally called TestToolsTaskEx.  With this new release, the task has the same name as the original v1 task, so that builds will be marked as failed when the tests fail.

If you downloaded the original release, you simply need to copy the Microsoft.TeamFoundation.Build.targets and Microsoft.TeamFoundation.PowerToys.Tasks.QualityTools.dll files from the zip to get the fix (see the Word doc for the paths).

Thanks to Thomas for pointing out this bug!

tags: , , , , , ,

Published Saturday, November 04, 2006 2:04 AM by buckh
Attachment(s): TestToolsTask-1.3.zip

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# 如何在沒有套用 Test Manager(.vsmdi 檔)下仍可採用 Team Build 與 整合 Testing

在執行 Team Build 時,如果要配套 Team Testing, 有個缺點,你必須要先採用 Test Manager 來歸類整理暨有的 Test Case. 這是個美意卻也造成一點缺點,因為如果你安裝的版本

Sunday, November 05, 2006 10:06 AM by Refines.Info["Polo Lee"]

# Bye Bye VSMDI

That blasted VSMDI file. Well Buck, Tom and crew did it. They have finally given us the ability to run

Monday, November 06, 2006 9:39 AM by Clark Sell

# Exactly what I've been waiting for!

Just wanted to pass on a big THANK YOU for putting this together.  While we do have team suite in house, I find it much simpler to just include all unit tests within a set of dll's and have them automagically added to the build.  I've only just added it to a few of our team builds, but so far it's working flawlessly!  

Monday, November 06, 2006 10:19 AM by Tim Dallmann

# Buck Hodges : How to run tests without test metadata files and test lists (.vsmdi files)

This has always been an issue for my customers! Link to Buck Hodges : How to run tests without test metadata

Monday, November 06, 2006 7:24 PM by adamga's WebLog

# re: How to run tests without test metadata files and test lists (.vsmdi files)

Awesome stuff! Must come in really handy...so, the "all tests" test list need is really obliviated now, ain't it?

Tuesday, November 07, 2006 12:52 AM by anutthara

# Improvements for Continuous Integration using TFS

One of the big complaints we've gotten from customers trying to build a Continuous Integration or similar

Tuesday, November 07, 2006 8:27 AM by bharry's WebLog

# Go Ahead Run your Tests in the Build

Tuesday, November 07, 2006 9:51 AM by Dave Lloyd's 2 Cents

# Improvements for Continuous Integration using TFS

Another project that sounds promising. Like the last, I've heard a lot of noise about this, as well as

Tuesday, November 07, 2006 10:18 AM by It's Way Too Early For This

# Running VSTS Tests without a test list

I have received this question a couple of times recently. When setting up a Team Build you have the option

Wednesday, November 08, 2006 4:22 AM by Ahmed Salijee

# re: How to run tests without test metadata files and test lists (.vsmdi files)

YES, this has been a thorn in our side for running tests in our nightly build.

Thanks for your efforts :)

Bob Hanson

Wednesday, November 08, 2006 4:51 PM by bob53050

# re: How to run tests without test metadata files and test lists (.vsmdi files)

This is just what we needed.  I've been updating those damn test lists on a daily basis just to keep up with our CI.

How many ways can I say thank you!

Wednesday, November 08, 2006 4:58 PM by David Boss

# re: How to run tests without test metadata files and test lists (.vsmdi files)

First of all thank you for the task. I have one question:

Using the task i am observing a slightly different behavior in Team Builds build status. Bevor using TestToolsTaskEx (using test lists) Team build sets the build status on a build with some failing tests to "FAILED". With TestToolsTaskEx Team build sets the build status of a build with some tests failung to "Successfully completed".

Is this intended or did i miss something in configuration?

Thursday, November 09, 2006 7:29 AM by Thomas

# re: How to run tests without test metadata files and test lists (.vsmdi files)

Thanks for the great feedback, everyone.

Thomas, you are correct.  Sorry, I missed that.  The difference seems to be a build step that's inserted by the original that's not there when using test containers.  I'll look into it and report back.

Buck

Thursday, November 09, 2006 10:42 PM by buckh

# re: How to run tests in a build without test metadata files and test lists (.vsmdi files)

Thomas, that was a bug in the original release.  I've updated the post and the attachment with the fix.

Thanks for reporting the problem!

Buck

Thursday, November 09, 2006 11:46 PM by buckh

# Updated version of new TestToolsTask

I've updated the TestToolsTask that supports using test containers, in addition to the test metadata

Thursday, November 09, 2006 11:59 PM by Buck Hodges

# re: How to run tests in a build without test metadata files and test lists (.vsmdi files)

Just one Question: What will happen to the Coverage when your Task is used. afik the assemblies for the coverage are namen within the vsmdi file?

Friday, November 10, 2006 11:02 AM by Ralf

# Want to run tests in Team Build without vsmdi files or test lists?

Buck has an update on his blog that explains how to run unit tests on Team Build without using vsmdi

Friday, November 10, 2006 11:26 AM by Anutthara's WebLog

# re: How to run tests in a build without test metadata files and test lists (.vsmdi files)

I know I must be missing something..

But anywyas,  I love your add-on, it will be so helpful. But I seem to have lost code coverage when I use it. When I ran the  TFS server  the old way I had code coverage (same project), so I’m lead to believe that I have set something up wrong. But before I go down the “What did I mess up path “, I want to make sure that your add-on supports code coverage. So is code coverage suppose to work?

Friday, November 10, 2006 1:09 PM by Joe

# Buck Hodges : Running Tests in a Build without Using .VSMDI Files

If you run tests as an MSBuild task in Team Foundation Build, you will probably be interested in a post

Friday, November 10, 2006 3:28 PM by Rob Caron

# re: How to run tests in a build without test metadata files and test lists (.vsmdi files)

Joe, Dominic Hopton states the following in the forums.

"You need to specify a .testrunconfig file (which has coverage turned on) to get code coverage with team build."

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=609672&SiteID=1

Buck

Friday, November 10, 2006 10:04 PM by buckh

# re: How to run tests in a build without test metadata files and test lists (.vsmdi files)

Buck,  Pardon me but I am new to all of this.  Just where am I supposed to specify the .testrunconfig file to use?  Is it part of the <TestContainerInOutput> tag?

Jay

Sunday, November 12, 2006 8:42 PM by Jay

# re: How to run tests in a build without test metadata files and test lists (.vsmdi files)

Jay, you would need to set the RunConfigFile property to specify the .testrunconfig file (see http://msdn2.microsoft.com/en-us/library/aa721750(VS.80).aspx for a list of all of the TestToolsTask properties).

The TestContainer and TestContainerInOutput tags are used to specify tests without having to use the MetaDataFile and TestLists properties (the VSTS for Testers SKU is required to generate test metadata files and test lists in VS2005).

Buck

Sunday, November 12, 2006 10:56 PM by buckh

# re: How to run tests in a build without test metadata files and test lists (.vsmdi files)

Buck,

I had Code Coverage  before, so I believe the Config file is correct. But I believe I have figured out the error. The project that does not work, is one of many projects in one Team Project. The problem I believe is that that the system looks for the  localtestrun.testrunconfig at the solution root, which is actually a folder above the project folder. This might be something I have done ( to mess this up that is). But I was able to overcome this be specifying the Config location in the  vsmdi and then reading it in the build.target. So for every vsmdi that does not work for CC I just point it to the correct file. If this isn’t necessary or I did something totally wrong, please let me know. And once again great add-on.

Thanks,

Joe

Example

Vsmdi

<ConfigLocation>E:\TeamBuilds\MainProj\Build Foo App\Sources\testFoo\localtestrun.testrunconfig</ConfigLocation>

Program Files\MSBuild\Microsoft\VisualStudio\v8.0\TeamBuild\Microsoft.TeamFoundation.Build.targets

   <!-- TestContainer tests for non-desktop builds. -->

   <TestToolsTask

         Condition=" '$(IsDesktopBuild)'!='true' and '%(TestContainer.Identity)' != '' "

         BuildFlavor="$(Flavor)"

         Platform="$(Platform)"

         PublishServer="$(TeamFoundationServerUrl)"

         PublishBuild="$(BuildNumber)"

         SearchPathRoot="$(SearchPathRoot)"

         PathToResultsFilesRoot="$(TestResultsRoot)"

         TestContainers="%(TestContainer.Identity)"

         RunConfigFile="$(ConfigLocation)"

         TeamProject="$(TeamProject)"

         ContinueOnError="true" />

   <!-- TestContainer tests for desktop builds. -->

   <TestToolsTask

         Condition=" '$(IsDesktopBuild)'=='true' and '%(TestContainer.Identity)' != '' "

         SearchPathRoot="$(SearchPathRoot)"

         PathToResultsFilesRoot="$(TestResultsRoot)"

         RunConfigFile="$(ConfigLocation)"

         TestContainers="%(TestContainer.Identity)"

         ContinueOnError="true" />

Monday, November 13, 2006 6:20 PM by Joe

# re: How to run tests in a build without test metadata files and test lists (.vsmdi files)

Okay, so the .vsmdi file allows the config file location to be specified.  Now it makes sense that the behavior would change when you switched away from the .vsmdi file.

So, did you actually modify the .targets file to use the ConfigLocation property, or did you somehow import the setting from the .vsmdi file?  Normally, that's the RunConfigFile property (has the same name as the TaskProperty).

Buck

Monday, November 13, 2006 9:13 PM by buckh

# re: How to run tests in a build without test metadata files and test lists (.vsmdi files)

I created a new property in the vsmdi called ConfigLocation  and then had the target read that location. I'm not sure where the system was getting the  org config location, but once I switched to your add-on it was not looking in the correct spot. So I just over-ridded the location and had it look at the vsmdi's property that I created.

Change in vmsdi (I added this)

<ConfigLocation>E:\TeamBuilds\MainProj\Build Foo App\Sources\testFoo\localtestrun.testrunconfig</ConfigLocation>

Change I did to the target:

RunConfigFile="$(ConfigLocation)"

Hope that makes sense.

Thanks,

Joe

Tuesday, November 14, 2006 10:36 AM by Joe

# re: How to run tests in a build without test metadata files and test lists (.vsmdi files)

Thanks for the clarification.  If the new property were called RunConfigFile rather than ConfigLocation, it would work without changing the .targets file.  Alternatively, you could put that setting in the TfsBuild.proj file.

Buck

Tuesday, November 14, 2006 11:04 AM by buckh

# re: How to run tests in a build without test metadata files and test lists (.vsmdi files)

Woops I said vmsdi. I meant the project file. But anyways, your suggestion works great. Thanks for all your help.

Joe

Wednesday, November 15, 2006 1:46 PM by Joe

# re: How to run tests in a build without test metadata files and test lists (.vsmdi files)

How can we specify the location of the testrunconfig file in the TfsBuild.proj file?  Can you provide an example?

Thanks,

Dylan

Wednesday, November 22, 2006 10:53 AM by Dylan Smith

# re: How to run tests in a build without test metadata files and test lists (.vsmdi files)

Dylan, you would need to set the RunConfigFile property in your TfsBuild.proj for the build type (via the standard msbuild <PropertyGroup> tag).  Team Build will pass that to the TestToolsTask.  You can find the documentation on the TestToolsTask's RunConfigFile property at http://msdn2.microsoft.com/en-gb/library/aa721750(VS.80).aspx.

Buck

Wednesday, November 22, 2006 11:40 PM by buckh

# re: How to run tests in a build without test metadata files and test lists (.vsmdi files)

thank you. I haven't tried it yet, but this was a LARGE annoyance for us since most people here just have Team Editon for developers

Wednesday, November 29, 2006 2:56 AM by Paul

# More on the Orcas features for Team Build

Brian Harry posted a TFS roadmap . I'd like to expand on the portion that describes the features specific

Saturday, December 02, 2006 12:33 AM by Buck Hodges

# Go Ahead Run your Tests in the Build

Do you want to be able to run tests in Team Build without having to use a .vsmdi file. Well now you can.

Wednesday, January 03, 2007 5:42 PM by Dave Lloyd's 2 Cents

# re: How to run tests in a build without test metadata files and test lists (.vsmdi files)

this 'hack' is a great thing!

To those who can't make it running properly - make sure you have in your TFSBuild.proj, tag <RunTest>true</RunTest>

On my installation it was false by default :)

Friday, January 05, 2007 5:42 AM by volt

# TFS: Automating unit tests as part of the Team Build

In my new project, we&#39;re using Team Foundation Server (TFS) as our source code repository and probably

Tuesday, February 13, 2007 11:24 AM by John Rayner's Blog

# Team Foundation Power Tools version 1.2 (aka TFS Power Toys)

We are happy to announce the release of version 1.2 of Team Foundation Power Tools (formerly known as

Wednesday, February 21, 2007 12:26 AM by Buck Hodges

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

Monday, March 19, 2007 2:44 PM by Benjamin Day Consulting, Inc.: The Blog

# Update to &quot;How to run tests in a build without test metadata files and test lists (.vsmdi files)&quot;: Test Categories

Pierre Greborio , a developer over in MSTV, has contributed a great new feature to the power tool task

Friday, April 27, 2007 10:04 PM by Buck Hodges

# VSTS unit testing and the .VSMDI

If you have done any serious unit testing with Visual Studio Team System and tried to include these tests

Tuesday, June 19, 2007 1:43 PM by Dave Lloyd's 2 Cents

# Run Non-

Run Non-

Thursday, July 05, 2007 3:17 PM by Benjamin Day Consulting, Inc.: The Blog

# How to enable code coverage without a test list

Aaron pointed out this post by Ben Day that talks about using the RunConfigFile property with a build

Thursday, July 05, 2007 9:14 PM by Buck Hodges

# How to enable code coverage without a test list

Aaron pointed out this post by Ben Day that talks about using the RunConfigFile property with a build

Thursday, July 05, 2007 10:08 PM by Noticias externas

# Visual Studio Team System Tip of the Week- Build lists not showing up in the build menu #1

Long ago i learned you really don't get to know your peers/peeps/coworkers until you spend an evening

Tuesday, March 25, 2008 6:55 PM by Ozzie Rules Blogging

# Team Foundation Build, Part 3: Creating a Build

This post was originally published here . In part 1 and 2 of this series, I gave an overview of Team

Thursday, March 27, 2008 6:51 PM by GrabBag

# 【日本語版】 (最新版) 「テスト メタデータ ファイルやテスト リスト (.vsmdi files) を使用せずにビルドでテストを実行する方法」: テスト カテゴリ

こんにちは! フォーラム オペレーターの服部清次です。 昨日に続きまして、 MSDN フォーラムの Team Foundation Server 関連 FAQ コンテンツ で紹介しました英語スレッドの日本語訳をもう

Monday, December 15, 2008 8:27 PM by Microsoft Japan Forum Operators Blog

# re: How to run tests in a build without test metadata files and test lists (.vsmdi files)

What part of this is still valid with TFS/Visual Studio 2008?

Thanks.

Tuesday, November 03, 2009 12:02 PM by ScTest

# re: How to run tests in a build without test metadata files and test lists (.vsmdi files)

ScTest, this functionality is built into the 2008 release.  In a tfsbuild.proj file generated by 2008, you will find a section with comments about how to use the feature.  You can also turn it on during the process of creating a new build definition in 2008.

Buck

Wednesday, November 04, 2009 9:22 AM by buckh

Leave a Comment

(required) 
required 
(required) 

  
Enter Code Here: Required
 
Page view tracker