Behaviour-Driven Development

A new micro-movement in the software development community attempts to reframe test-driven development as behaviour-driven development. This is an attempt to overcome the backwardness of test-first development. If I want to test something, I need to have that something first, right? So writing tests for something that doesn’t even exist is a pretty weird concept.

Call it behaviour-driven development (BDD) and it all makes sense. You are defining your code’s behaviour before actually writing it.

There’s a framework called jBehave (dig the logo!) that’s a kind of JUnit for BDD. Instead of unit tests with names like this:

testCreation
testAddOneWidget
testFindWidgetByName

you would write behiour assertions like this:

shouldBeEmptyOnCreation
shouldBeSizeOneAfterAddingOneWidget
shouldFindRightWidgetByName

Well, that’s just changing some words, but it seems like an important conceptual leap to me. We are not writing tests anymore. We are defining the behaviour of code in an automatically verifiable way.

I’ve also heard the term example-driven development for the same concept.

Something to keep an eye on.

(via Tim Bray)

This entry was posted in General. Bookmark the permalink.