jacksonh.tumblr.com

Notes &

Oh, so that’s why you people have such long unit test names.

I’m sure I’m the last person in the world to learn this one, but here is an incredibly useful naming convention for unit test methods:

 public void [TargetMethod]_[Scenario]_[Expectation] ()

So a typical test would look something like this:

 public void OpenFile_FileIsNull_ThrowsArgumentNull ()

I had always found those long method names ugly, but now that I know there is a method to the madness they look beautiful to me. Also, the method name length doesn’t really matter, because no one is ever going to call that method, it should only be called by the testing framework.

If you found this blog entry at all informative I highly reccomend you get a copy of Roy Osherove’s The Art of Unit Testing.