I find these test names cumbersome to the point of being confusing; method names are not camelcased sentences.
If you want to go with "readable" test method names - try to make it easier to read the method name than the code (which is what a 12 word method name is likely to make a reader do). Here are some suggestions for DoorIsNotVirtualIfNameStartsWithLetterOtherThanV -
- The class is testing the class door - all methods in this test case will test something in the door class - the word door is not necessary.
IsNotVirtualIfNameStartsWithLetterOtherThanV
- Remove words that don't add meaning
notVirtualIfNameStartsLetterOtherThanV
notVirtualIfNameFirstCharNotV
- Double negatives are confusing
notVirtualIfNameFirstCharR
But. What's wrong with
[TestClass]
public class DoorTests
{
[TestMethod]
/**
* Virtual doors only start with V
*/
public void testIsVirtual()
{
var door = new Door {Name = "V001"};
Assert.IsTrue(door.IsVirtual, "Door $door$ is not virtual but was expected to be");
}
[TestMethod]
/**
* Real doors don't start with V, and usually start with R
*/
public void testIsVirtualFalse()
{
var door = new Door {Name = "R143"};
Assert.IsFalse(door.IsVirtual, "Door $door$ isVirtual, but was expected not to be");
}
}
If you have more permutations of similar tests - use a (short) suffix. Just ensure the message when an assert fails gives all the detail you'd want to know what the failure means, or the docs for the failing test clearly guide the developer to understand the error. Replacing docs and error messages with "meaningful method names" just makes code tiresome to read.