November 23, 2007
I’ve started looking at Behavior-Driven Development (BDD) and more specifically RSpec for Ruby. BDD is an evolution of Test-Driven Development (TDD) which aims to make developers look at it from another perspective and not regard it as testing in a sense. So it’s more of a new way of expressing your intent rather than an entirely new approach to tests (or specs as the BDD community calls it).
You divide your code into small pieces of behavior, rather than the more abstract term units and write what it should do.
Here are two examples of the difference:
|Assert.AreEqual(expected, actual)||actual.should equal expected|
I just watched a video where Dave Astels (one of the guys behind RSpec) explains why you should take a look at BDD if you’re into TDD. To quote him: “Behaviour Driven Development is what you were doing already if you were doing Test Driven Development very well”. You can also read his PDF A new look at test-driven development (8 pages) where he explains his views and why too few people “really understand what it’s really about. That means that many people who practice TDD are not getting the full benefit from it”.