Tuesday, January 15, 2008

Behavior Driven Development

I was looking at RSpec(http://rspec.info/) as I want to use it in a open source project. The definition of RSpec says that its a Behavior Driven Development framework for Ruby. As a TDD practitioner, I have been writing tests using xUnit frameworks. This will be my first experience with BDD frameworks. But how BDD differs from TDD ?

In test driven development we write tests before we code. However, testing the code and application is not the sole purpose of writing tests.TDD is not only about writing tests. Its about writing specifications for individual piece of code in form of tests, which should (ideally) lead to better design. So TDD is about specifying requirements and design and not only testing. BDD makes this fact explicit. It uses proper vocabulary and has emphasis on using the proper words (e.g. specification instead of tests). BDD gives more emphasis on coming up with the behaviour and specification rather than tests.

BDD is not a radically new way of thinking (like TDD is). Its just a improvement, a next step in TDD thinking. It combines the aspects of Domain Driven Design with TDD. It defers from TDD in a sense that we specify behaviour of the application rather than testing its implementation.However, just like TDD, we should do it in small steps, writing down the specification for small part of app before the part is implemented.

BDD uses Ubiquitous language - language which is equally understood by developers and users. Rspec, which a Behavior Driven Development framework for Ruby, allows us to define specifications in language such as "should add two numbers" or "should have score greater than 50". This kind of specification is more intuitive than unit tests.

So in short, BDD frameworks allows us to write executable specification and acceptance criteria. However, I still have some questions like - Can we do BDD with xUnit frameworks which are defined for TDD ? Do we still need unit tests to test the application at granular level or we should use BDD framework for that purpose? Hopefully, answers to these questions will be clear once I become more familiar to BDD style.

7 comments:

shreekavi said...


Wonderful blog. It is really informative to all.keep update more information about this
Software Testing Course in Bangalore
Software Testing Course in Hyderabad
Software Testing Course in Pune
Software Testing Training in Gurgaon

vanhelsing said...
This comment has been removed by the author.
vanhelsing said...
This comment has been removed by the author.
vanhelsing said...

Wonderful blog. Thanks for sharing a useful information....
Google Ads Training Courses In Chennai
Google Adwords Online Course

bruce wayne said...

Great blog.thanks for sharing such a useful information
Salesforce CRM Training in Chennai

Dhilshan said...

Happy to read the informative blog. Thanks for sharing
best selenium training center in chennai
best training institute for selenium in chennai

Matt Reeves said...

This post is so interactive and informative.keep update more information...
Angularjs Training in Tambaram
Angularjs Training in Chennai