wood burning stoves
The moose likes Design and the fly likes Pros and cons of BDD against TDD Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Design
Bookmark "Pros and cons of BDD against TDD" Watch "Pros and cons of BDD against TDD" New topic

Pros and cons of BDD against TDD

Nrupay Shah

Joined: Dec 27, 2010
Posts: 3
Why to use BDD and what are the main advantages of BDD?
John Smart
Ranch Hand

Joined: Aug 06, 2013
Posts: 43
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

Joined: Oct 01, 2001
Posts: 814

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.


SCJP, SCJD, SCEA 5 "Any sufficiently analyzed magic is indistinguishable from science!" Agatha Heterodyne (Girl Genius)
I agree. Here's the link: http://aspose.com/file-tools
subject: Pros and cons of BDD against TDD
It's not a secret anymore!