Wednesday, April 1, 2009

How to enable or disable Visual Studio Team Test integration

Gallio provides integration with Visual Studio Team Test so that you can run your tests using the built-in Visual Studio Test View and other tools.

However to make this work, the project file must be configured with an extra "ProjectTypeGuid" that that informs Visual Studio that the project should be considered a Test Project.  By adding or removing this element you can enable or disable support for Visual Studio Team Test.


  • We do not install the Visual Studio Team Test integration by default anymore beginning with v3.0.6 if you perform a "Typical" install.  You will need to perform a "Complete" installation or ensure that the "Visual Studio Team System Test Runner" component under "Test Runners" is installed as part of a "Custom" installation.
  • The built-in MbUnit project templates already contain the appropriate ProjectTypeGuids, so if you create a new project that way then it should just work out of the box.
  • Some editions of Visual Studio lack support for Test Projects and will refuse to open up any project that contains the special guid!  In this case you may have to remove the offending guid so that you can work with your projects.
  • The Visual Studio Team Test integration is very rough.  It has poor performance due to several issues including the fact that Visual Studio wants to populate its list of tests in the foreground after compiling a test project.  So the GUI may hang for some time after each build if the Test View is open and you have a big test project.  I really hope they fix this in Visual Studio 2010.
  • At this time, the integration only works with MbUnit v2, MbUnit v3 and  Unfotunately csUnit and NUnit do not support the use of an abstract reflection policy so they are not supported by this feature.  However, there does exist another Visual Studio Team Test add-in for NUnit.

In all honesty, I would recommend using TestDriven.Net or ReSharper to run your tests inside Visual Studio instead of using the Test View.

Editing Project Files

Visual Studio uses a magic "ProjectTypeGuid" to determine whether it should consider a given project to be a Test Project.  Only Test Projects are considered when populating the Test View.

And the magic guid is... {3AC096D0-A1C2-E12C-1390-A8335801FDAB}

Here's how to edit the files:

1. Open up the *.csproj or *.vbproj file in a text editor.  It's just XML (actually an MSBuild build script).

2. Within the first <PropertyGroup> element at the top of the file, look for an existing <ProjectTypeGuids> element.

2a. If you found the <ProjectTypeGuids> element, then add the aforementioned Guid to the list within if not already present.  Be sure to separate the guids with semicolons.

2b. If you did not find a <ProjectTypeGuids> element, then copy and paste in the appropriate element below.

  • C# Projects: *.csproj


  • Visual Basic Projects: *.vbproj


3. Save the project file.

4. Reload the project in Visual Studio.

5. Open up the Test View.  The tests in your project should now be populated.

It's Too Slow... How Do I Turn It Off?

If you read the caveats above, I warned you... :-)

There are three ways to turn this off.  Any one of them will suffice.

1. Remove the ProjectTypeGuid just added above then reload the project.

2. Disable the Gallio add-in using the Visual Studio Add-In Manager.  Contrary to what some people expect, this will not in any way affect the ReSharper integration.

3. Uninstall the "Visual Studio Team System Test Runner" component.  You don't need to uninstall all of Gallio for this.  Use the Add/Remove programs control panel to Change the set of installed features and look under the "Test Runners" part of the tree.

What The Future Holds...

I do have a hack in mind for improving performance by populating the Visual Studio test list asynchronously although it would run contrary to the stated API contracts.  So if the performance is a problem for you but you really really want to use the Visual Studio Team Test controls, please let me know and I'll raise the priority of this task.  Also I could use a volunteer to help make the integration more compelling overall.

Also, some time ago I started working on a different native Visual Studio add-in for Gallio called Sail.  It's not ready yet but something I've been thinking about again lately...  If you'd like to help, let me know.

Technorati Tags: ,

No comments: