Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Pros and cons of BDD against TDD

 
Nrupay Shah
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why to use BDD and what are the main advantages of BDD?
 
John Smart
Author
Ranch Hand
Posts: 43
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Compared to TDD, BDD is more .

At the unit testing level, BDD can be considered an easier and more evolved variation on TDD, where the emphasis is on writing "executable specifications" rather than just unit tests. Like TDD, BDD involves writing the tests first, in order to design clean, effective and well-documented code. Testing is useful but secondary. BDD expresses the tests in terms of specifications that illustrate what the code should do using a number of concrete examples. The core idea is the same as TDD, but thinking in terms of "specifications" makes it easier to focus on what the code should do (the "what") rather than the implementation (the "how"). There are dedicated BDD unit testing tools, but you can do BDD with classic unit testing tools like JUnit or NUnit.

BDD is also generally easier to learn than TDD.

Unlike TDD, BDD principles and tools also work well at the requirements level, where requirements are discovered and discussed in terms of high-level examples (or "scenarios"), in conversations between the team and the stakeholders. This is an extremely effective way to ensure that the whole team has a good understanding of what needs to be build, and can also lead to automated acceptance criteria based on these examples.
 
Burk Hufnagel
Ranch Hand
Posts: 814
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nrupay,

I hope you don't mind me throwing in my two cents.

Your subject line says "Pros and cons of BDD against TDD" - I don't think that's the attitude you want for this. I think it should be BDD *and* TDD working together. BDD gives you a high level look at the expected behavior of a class or a program, and those expected behaviors can be used to help you discover the various unit tests needed to ensure the expected behavior happens.

For a class with simple behaviors you may not need BDD, but when business logic is involved, it makes more sense to specify what should be done under various circumstances - and that's when BDD shines.

Well, that's my opinion and I hope it makes sense. If not please say so and help me understand better.

Thanks!
Burk
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic