Converting a csproj into a test csproj

Short answer.

It's as simple as adding one line to your csproj which in turn tells the IDE to treat that project like a test project.  Add the following line to your main PropertyGroup:

<ProjectGuid>{04082EBA-C85C-4336-B3FD-9891096BAA0F}</ProjectGuid>

Then just reference Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll and you are on your way. Be sure to verify that Guid between releases. 

Long Answer.

When I start a project I create the base set of known assemblies that project will need. I also add an additional test project which will contain any Scenario, Load and Stored Procedure tests. Then I convert all assemblies to test projects. I am a firm believer in Test Driven Development. IMHO it is the only way to properly write code. Having said that over the years I have developed my own set of TDD practices; one of which is the physical placement of your unit test classes in the assembly their testing. Why? Well I will explain that in a future post call Unit Testing with Partial Classes.

With any decision there are of course trade-offs. In this case the trade-off is around the IDE interaction with hosting type projects, ie exe or web. After you convert an exe to a test project, when you decide to run ( F5 ) it will actually fire off Test Manager rather than the launch app. If you are a TDD bigot like me this is actually the correct action; if your not, I know your already complaining. BUT all is not lost! There is a little tool us TDD bigots keep in our back pocket at all times, TestDriven.Net. This is an Visual Studio add-in and it allows you to execute your unit tests with just a right click. If you choose to use this tool it isn't necessary to convert your project to a test project but rather just reference the Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll. This will allow you to fire your app as intended and run your tests with the same project configuration.

Disclaimer: this is not a Microsoft recommend practice. You can find more information about the Visual Studio Team System Testing Framework here.