"Not a test class" - Backward unit test compatibility from VS 2008 to VS 2005 Team System

Published 01 September 08 04:56 PM | dmckinstry

Awhile ago I was working with a client and received an error message "UTA052: MyNamespace.MyTest is not a test class" after converting a unit test project created in Visual Studio 2008 to Visual Studio 2005 Team Edition.  (Actually it was a VS 2005 nUnit/BizUnit test project converted to VS 2008 MSTest and then to VS 2005 MSTest.) The path I chose wasn't necessarily supported but it was necessary.  The nearest help I could find was from MSDN Forums: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3820523&SiteID=1&mode=1.  Luckily I figured out the cause of the problem and a solution.  If you have run into this message and said to yourself "but it IS a test class," read on...

The scenario that led to my this problem was the conversion of a VS 2005 nUnit project to VS 2008.  As expected, when I opened the VS 2005 project with VS 2008, Visual Studio successfully converted the project to Visual Studio 2008 format.  I then went through the required search-and-replace and reference changes to modify the nUnit tests to be Microsoft-format tests.  This was the easy part.

Next, I had to convert the project back into Visual Studio 2005 format. Why? The original conversion to 2008 was a convenience that I knew I'd have to undo...  The test project was in support of BizTalk 2006 R2, which is developed in VS 2005, not 2008.  I wanted to maintain the test project in the same tools as the test target.

In many cases, you can revert a VS 2008 .NET 2.0 project to VS 2005 by simply changing a few characters in the .SLN, .VBPROJ and/or .CSPROJ files.  In the following snippet, changing the "10.00" to "9.0" may result in converting the solution back to Visual Studio 2005.  A similar exercise may be necessary for the project files but I'll leave the specifics to you.

image

After bringing the solutions and project back to Visual Studio 2005, I did some minor cleanup and recreated the VSMDI and TestRunConfig files.  The solution compiled without issue but when I tried to run the tests I received the aforementioned message: "Error xxx UTA052: MyNamespace.MyTest is not a test class".  Of course the source code looked fine.  So after all that, what is the punchline?  I had the wrong reference.  I was referencing the 9.0 version of Microsoft.VisualStudio.QualityTools.UnitTestFramework.  Since my system had both Visual Studio 2005 and 2008 installed and the 9.0 DLL is compatible with .NET 2.0, I didn't have any issues with compilation.  But the 2005 version of MSTest did no recognize the 8.0 version of the testing tools, hence the error.

Although this may be a niche problem, hopefully this blog posting will help someone else trying to perform similar unit test surgery find the solution faster.

Comments

# funny wallpaper » “Not a test class” - Backward unit test compatibility from VS 2008 to VS 2005 Team System said on September 1, 2008 07:15 PM:

Pingback from  funny wallpaper » “Not a test class” - Backward unit test compatibility from VS 2008 to VS 2005 Team System

# Team System News said on September 4, 2008 09:15 AM:

Eugene Zakehareyev on Getting Latest in VS2008 (addendum) and Renaming Team Project in VS2008 - nothing...

Leave a Comment

(required) 
(required) 
(optional)
(required)