Thursday, 29 August 2013


Why is Behaviour Driven Development better than Test Driven Development? Why should I switch to BDD?”

Well BDD focuses on specifying what will happen next. where as TDD focuses on setting up a set of conditions and then looking at the output. 


Behaviour driven development comes from TDD and focuses more on the expected/desired behaviour of your application and using this to drive your design and development process. Generally BDD focuses on obtaining a clear understanding of desired software behaviour through discussion with stakeholders. It extends TDD by writing test cases in a natural language that non-programmers can read. Behaviour-driven developers use their native language in combination with the ubiquitous language of domain driven design to describe the purpose and benefit of their code. This allows the developers to focus on why the code should be created, rather than the technical details, and minimizes translation between the technical language in which the code is written and the domain language spoken by the business, users, stakeholders, project management, etc.
BDD is a second-generation, outside-in, pull-based, multiple-stakeholder, multiple-scale, high-automation, agile methodology. It describes a cycle of interactions with well-defined outputs, resulting in the delivery of working, tested software that matters.


Test Driven Development is all about writing tests first. This basically forces you to write your own client before you write your application code. The cycle is generally write a test for an API that doesn’t exist, run the test expecting it to fail, go write your API code, run your test again and make sure it passes. Then write your next test… and so on.
Once the test passes, observe the resulting design and refractor to remove any duplication you see. It is natural at this point to judge the design as too simple to handle all of the responsibilities this code will have.

If person adhere more strongly to TDD principles he spend less time reworking later. The amount of time spent is all in how well you write unit tests though. If the unit tests don’t capture the expected behaviour, all the time spent on them is wasted.

Differences between BDD and TDD

1) BDD focuses on specifying what will happen next. where as TDD focuses on setting up a set of conditions and then looking at the output.

2) BDD specifies behaviours while TDD specifies outcomes.

3) BDD can be layered, while outcomes(TDD) cannot.

4) TDD is for testing and we can't perform Design process, Requirements capturing and Behaviour specification in TDD, but these can be possible in BDD.

5) BDD is mainly used as a communication tool. its main goal is to write executable specifications which can be understood by the domain experts.

The main difference between BDD and TDD is wording. as these are important for communicating your intend.
Post a Comment