Thursday, November 29, 2007
Mr. Boodhoo to the rescue once again. I recently posted about how I
really liked the Behavior Driven Development approach to building an application test-first, but I was
struggling with the naming conventions I was coming up with when trying to organize and group my tests and fixtures using the same BDD contexts.
Apparently after a recent pairing session with
Scott Bellware, JP came up with a solution that is both elegant and ridiculously simple. It seems distilling challenges into elegant and simple solutions is something JP does 20-30 times a day, leaving observers with big red hand prints on their foreheads, mumbling "why couldn't I think of that?" That's what makes him the
Michael Jordan of .NET. The irony behind the "Nothin' But .NET" name for the training he offers is not lost on me! And let's not forget Scott, who I think JP has credited as inspiring the whole BDD approach and test naming style he has adopted. Maybe that makes Scott the
Dennis Rodman of .NET? I leave that to the fans to debate.
To summarize, he names his Classes (and corresponding files) as <SystemUnderTest>Specs, and then creates separate classes inside that specs class for each context. My stumbling point was that I was naming my classes by context, and couldn't think of a clean way to group by SystemUnderTest, and was ending up with horrible class names.
Read his
full post to see how this style breaks down into a very useful specification for your system, and helps you stay focused in and clear with TDD.