This post originated from an RSS feed registered with Ruby Buzz
by Eric Hodel.
Original Post: BDD vs. TDD
Feed Title: Segment7
Feed URL: http://blog.segment7.net/articles.rss
Feed Description: Posts about and around Ruby, MetaRuby, ruby2c, ZenTest and work at The Robot Co-op.
At both Canada on Rails and the Silicon Valley Ruby Conference I watched talks on Behavior Driven Development with RSpec, the former given by Dave Astels and the latter by Steven Baker. At SVRC one person asked why we need a new testing framework and Steven replied that BDD changes the way you think about TDD.
As I gained experience with TDD my failing test cases expressed the next piece of behavior I wanted my object to have. Learning how to do this took me about a year because I didn’t know how to think properly. BDD is designed to get you to think correctly about what you are testing, but it is hard to communicate how you should think about writing code.
With Test::Unit it is too easy to run off chasing edge cases that typically aren’t important. I did this back when I was new to testing and ended up with big, ugly tests that didn’t make my development much better. RSpec discourages edge-case chasing by expressing the tests at a higher level.
I think the only thing missing from the two presentations was a set of slides that show a small session of BDD like Steven displayed on classic TDD at Canada on Rails. The examples on the RSpec page are fully formed, so you can’t see the specification develop over time along with the code.