TDD and BDD?


TDD?

http://stackoverflow.com/questions/1386562/how-to-get-started-on-tdd-with-ruby-on-rails

TDD is all about writing tests first. This basically forces you to write your own client before you write your application code.The reason I’ve always favored TDD development is that it focuses how I will implement a specific piece of 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 refactor toremove 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 behavior, all the time spent on them is wasted.

BDD?

http://stackoverflow.com/questions/485893/what-is-the-path-to-learn-bdd-on-ruby-on-rails

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.BDD focuses on obtaining a clear understanding of desired software behavior through discussion with stakeholders. It extends TDD by writing test cases in a natural language that non-programmers can read. Behavior-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.

Difference between TDD and BDD?

http://railsforum.com/viewtopic.php?id=22763

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 Behavior specification in TDD, but these can be possible in BDD.

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

6). the main difference between BDD and TDD is wording. as these are important for communicating your intend.

BDD

Given the user is logged in
*** test code***
And they are an administrator
***test code***
When the deleteUser is called
***test code***
Then the user will be removed from the system
***test code***
And they will also be removed from any groups they belong to
***test code***

TDD (done badly)

Test SomeClass delete method()
***test code***

The top one can be read and understood by a domain expert, the bottom one the reader would have to guess the intended behaviour by reading the test code.

The advantage of BDD is that the same semantics can also be used for user stories and acceptance criteria. Therefore acting as a bridge between specification and code.

Advertisements

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