Home > Uncategorized, Unit Testing > Behavior Driven Development

Behavior Driven Development

I had read some articles about BDD like Dan North’s article on BDD and the information on this site. However, I never quite got a hang of it. I’ve also looked at the Specter Framework which is a BDD framework in Boo. But again, since Boo is not used heavily (in the .Net world), it becomes a problem, because you have to install a new language / compiler etc. and then, the company you are working for, should allow its usage.

I understood the basics behind BDD, the difference in nomenclature (from TDD) but I could never start writing tests first. Then I came across this article by Scott Bellware and his SpecUnit.Net helpers for NUnit. I believe these helpers are easy to work with, once you get a hang of them. Scott left one of the specifications as an execise to the reader, so here’s my take at it –

Specification code

Specification code

And here’s the resulting change to the Account class –

Account class

Account class

I believe, that this style of writing behaviors (aka tests) first, will help us to flesh out the domain model classes (which is obviously the heart and soul of any application). However, my doubt is – is this style suited only for arriving at the domain model classes? Please let me know your views and comments.

Thanks Scott for a detailed and insightful article and the SpecUnit helpers.

Advertisements
  1. August 24, 2008 at 12:46 am

    > is this style suited only for arriving at the domain model classes?

    I use this style of specification and language for every aspect and layer of an application. Because I tend to write my specifications to the experience of the app and not let implementation details leak into either the context names or specification names, the same language above could be found in specifications against the domain model, the user interface, the services layer, or even a REST or SOAP API.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: