Test Naming - Kevlin Henney Style

Naming tests is hard. For unit test beginners I have recommended Roy Osherove’s naming until now.

Here’s an example in C# with NUnit testing the string.ToUpper method:

[TestFixture]
public class Test_String

[Test]
public void ToUpper_someUpperCaseLetters_AllLettersAreUpperCased() { /*test implementation*/ }

It is an easy way get started with testing without having the naming of the tests getting in the way. In the beginning just writing the test is hard enough already. However recently I saw another way of naming that might be easy enough for even beginners.

I saw this other way of naming in the talk “Seven Ineffective Coding Habits of Many Programmers” by Kevlin Henney from the NDC 2014 conference. I really recommend that talk and it’s available at http://vimeo.com/97329157. If you just want to see the part about test naming skip to 58:48, but you should really watch it all if you have the time.