Tuesday, September 30, 2014

Unit Test Template for VS2013

Problem
Starting in VS2012 Microsoft removed the Generate Unit Tests option from the context menu, because it was just too efficient. With good intentions these people were kind enough to create an almost replacement, here: http://visualstudiogallery.msdn.microsoft.com/45208924-e7b0-45df-8cff-165b505a38d7. Too bad it only works on public methods (in other words, it doesn't work with internal methods!).

Solution
Fine, i'll just save this unit test template to the testing project, and copy and paste every time i want to test a method. At least Microsoft won't be able to take this away from me.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace UnitTestingProjectName
{
    [TestClass()]
    public class UnitTestClassName
    {
        [TestMethod()]
        public void UnitTestMethodName()
        {
            //Arrange

            //Act

            //Assert
        }
    }
}

No comments:

Post a Comment

There was an error in this gadget