Unit Test Method Naming
As mentioned in a previous post, having a clear naming convention for unit test methods is important to keep tests readable and maintainable. Sticking to the convention might be difficult at first and require some discipline but is definitely worth it in the long run.
Visual Studio Snippets
In order to make it easy for myself (and other developers) to use the
<UnitOfWork> _ <StateUnderTest> _ <ExpectedBehaviour> naming convention, I’ve created two code snippets, one for NUnit and one for MSTest.
After importing the snippets (see below) you can use the them by typing:
nutest[TAB] (for NUnit)
mstest[TAB] (for MSTest)
The resulting code is displayed at the top of this post. The snippets use three placeholders (marked in yellow) which make up the method name using the suggested convention. In addition I’ve added Arrange, Act, Assert comments in order to help structuring the test.