Behavior Driven Development

Today at SD West 2006 I took a hands-on session with Dave Astels on using rSpec. Dave’s primary message was we shouldn’t be talking about the word test in test driven development, but we should focus on behavior. Really when you’re doing TDD you’re specifying what the code should do not verifying that code works.

It’s an argument that seems to be picking up steam which is partly the idea of changing Test Driven Development to Test First Design or Test Driven Design. rSpec is essentially a replacement for xUnit in Ruby that focuses on nice English syntax for expectations in the form of:

should.have.at.least(5).items

I’ve seen something like this in Java as well with the JBehave project or Agiledox, but rSpec seems to be making some pretty nice progress. The exercise was to implement the game of Deflexion with a full set of expectations. It was a pretty well thought out exercise for a half-day tutorial and Dave was able to spend time wandering around answering questions effectively.

The surprising thing was I paired up with another developer who gets to do a lot of XP in his day job and we really marched our way through the tutorial. We managed to get through 24 tests, I mean expectations, in about 2.5 hours. Not that surprising unless you consider I’m a relative newbie to Ruby and he was a complete newbie, though probably a better pure coder. As a bonus I understand Ruby modules and their syntax a lot better now.

Anyway I’ll be working my way through the complete tutorial tonight, because Ruby and behavior-driven development is just a lot of fun.

5 responses to “Behavior Driven Development”

  1. Kevin got me hooked on this “wacky design idea” (http://makeashorterlink.com/?U43561EDC) of using should when I write my JUnit tests. That one idea has been the difference between writing testValidate and testValidateShouldPassWithAllFieldsSet.

  2. Ed Gibbs says:

    I like it, sort of the idea behind longer descriptive test method names. In rSpec there’s really few constraints on naming, but then I have to code in Java for my day job.

  3. Keith says:

    If you would be interested in rspec like approach which may port into java more easily, you might like to look at my javascript implementation. The code may be a bit ropey but I think the ideas may be valid. I am after some feedback. many thanks in advance.

    Keith

  4. […] haven’t really spent a lot of time with RSpec since about the 0.5 release. I took a tutorial class with Dave Astels and got jazzed about the opportunity since they were […]