This last week I took a great class on TDD and BDD given by Scott Bellware. During  the session   he showed us a cool tool called AutoHotKey. AutoHotKey is a tool that allows you to control your keyboard behaviors. For instance you can use AutoHotKey to substitute the underscore character for a space when typing in a test name

I had a discussion with my co-worker Greg Lawrence about using underscores vs.  CamelCase for our test naming conventions. I have always liked underscores in test names. Test names are like sentences and should be read as such. To drive this point home (and to demonstrate it for an underscore bigot :) I present the following:

Original Test

We hold these truths to be self-evident, that all men are created equal,
that they are endowed by their Creator with certain unalienable Rights, that among these are Life, Liberty and the pursuit of Happiness.

CamelCase

WeHoldTheseTruthsToBeSelfEvidentThatAllMenAreCreatedEqualThatTheyAreEndowed…WithCertainUnalienableRightsThatAmongTheseAreLifeLibertyAndThePursuitOfHappiness.

Underscored

We_hold_these_truths_to_be_self_evident_that_all_men_are_created_equal_that_they_are_endowed_…with_certain_unalienable_rights_that_are_among_these_are_life_liberty_and_the_pursuit_of_happiness

BDD CamelCase Notation

WhenMenAreEndowedWithUnalienableRights

  • ShouldIncludeLife
  • ShouldIncludeLiberty
  • ShouldIncludeHappiness

BDD Notation (Underscored)

When_Men_Are_Endowed_With_Unalienable_Rights

  • Should_Include_Life
  • Should_Include_Liberty
  • Should_Include_Happiness

As is self evident (pun intended) the underscored version is much easier to understand and read.  When you generate documentation from your BDD specs which one make more sense? Which will is easier to use by your customers? Which ones can you substitute underscores for spaces when printing documentation? Its pretty obvious which one to choose.

Just a small thought on this march morning.