Converting NUnit Visual Studio project to VSTS Test project

I have been a big fan of NUnit coupled with Resharper. Both of them combined, just provide a friction free development, thus encouraging myself to write more unit tests.However, being a part of the team, I have to make sure that my tests can also be run by other people. The decision was made to use VSTS Testing Tools. So today I had to migrate my Unit tests from NUnit to VSTS.

The biggest problem was to convert the Visual Studio project from a 'normal' class library, to a VSTS Test Project. This needs to be done, otherwise all the test methods inside the project will not be 'detected' as test cases.

These are the complete transition steps:

  1. Convert the NUnit test project (Visual Studio Class Library Project) to a VSTS Test Project
    this is done by modifying the csproj and adding a 'ProjectTypeGuids'

    
      
        ...    
        {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
      
      ...
    
  2. Convert all the attributes to VSTS's
    [TestFixture] into [TestClass], and
    [Test] into [TestMethod], and
    [SetupTestFixture] into [ClassInitialize], etc ..
    adjust the reference accordingly
  3. Add TestContext Property
    public TestContext TestContext { get; set; }

Done!

  1. says:

    why would you though??? WHY?

  2. says:

    Yes, it was a stupid move. I regret it so much. Then again, by adding the NUnit tags back in, the project then can be read by both framework.