On the Naming of Tests

November 4, 2013
tech

I’d thought that this was part of the automated testing canon already, but apparently not, so a quick note on the naming of tests appears to be in order. Well, how I think tests should be named. :)

When using an xUnit-style framework, the common pattern is to test class Foo in another class called FooTest. Within this test class, there are several methods. The principle I like to follow is that if you took the name of the test class, stripped off the “Test” postfix, and then listed the names of the tests as bullet points, you’d end up with a list of roles and responsibilities of the class under test. You’d end up with something like:

Foo  
  * Should eat cheese  
  * Should not consider cake as cheese  
  * Should handle null cheese by throwing a SpecificException  
  

And so on.

Put another way, if someone were to delete the class under test and the bodies of the tests, could they recreate something functionally identical to the class under test using just the test names?

More recently A Ranty and Dogmatic Troll Masquerading as Coding Guidelines     Time Keeps Ticking Less recently

Migration Complete?

August 31, 2020
tech writing

Regular and Infrequent Performance Reviews

August 22, 2020
people tech

Rebuilding the Site

July 27, 2020
tech