BDD, RSpec and RUnit

Posted by Jeremy Voorhis Wed, 28 Sep 2005 04:04:00 GMT

Today on #ruby-lang, I was enlightened to the latest XP-inspired testing paradigm: Behaviour Driven Development, as well as srbaker’s implementation of RSpec. It seems like a really great idea – testing semantically, rather than per-module or per-method. I’m not quite sure, however, why a new testing framework is needed. Today, I wrote multiple tests for a method with RUnit:

Event#find_event_in_range_of_time is tested with EventTest#test_find_event_in_range_of_time_for_organization

and

EventTest#test_find_event_in_range_of_time_for_range.

Granted, I haven’t tried RSpec yet, and I do not want to discount srbaker’s work – he is a smart developer – but I am not sure why another testing framework is needed for Ruby. It seems like either way you end up with a somewhat larger mass of tests for specific behaviours, and RUnit is nicely baked into Rails.

Any comments, guys?

Comments

  1. Michael Granger said 19 days later:

    I think you mean Test::Unit. RUnit is an older, deprecated test framework.

    RSpec, and BDD in general, is an effort to change the way developers think about how they design/create their code. BDD is supposed to make you think in terms of specification instead of verification, which is a subtle but significant difference. Dave Astels’ paper which followed the article you linked (here: http://daveastels.com/files/sdbp2005/BDD%20Intro.pdf) on the subject is a must-read.

    I’m not sure I completely buy into some of the more-radical opinions I’ve heard surrounding BDD yet, but I think the overall idea has merit. I find RSpec to be much more Rubyish in its syntax, using left-to-right chains of methods for specification instead of functional-type assertions. That’s not to say that you couldn’t drive Test::Unit that way.

Trackbacks

Use the following link to trackback from your own site:
http://www.jvoorhis.com/articles/trackback/34

(leave url/email »)