TDD and BDD Differences

TestingTddBdd

Testing Problem Overview


I honestly don't see the difference between BDD and TDD. I mean, both are just tests if what is expected happens. I've seen BDD Tests that are so fleshed out they practically count as TDD tests, and I've seen TDD tests that are so vague that they black box a lot of code. Let's just say I'm pretty convinced that having both is better.

Here's a fun question though. Where do I start? Do I start out with high level BDD tests? Do I start out with low level TDD tests?

Testing Solutions


Solution 1 - Testing

> I honestly don't see the difference between BDD and TDD.

That's because there isn't any.

> I mean, both are just tests if what is expected happens.

That's wrong. BDD and TDD have absolutely nothing whatsoever to do with testing. None. Nada. Zilch. Zip. Nix. Not in the slightest.

Unfortunately, TDD has the word "test" in pretty much everything (not only in its name, but also in test framework, unit test, TestCase (the class you tpyically inherit from), FooTest (the class which typically holds your tests), testBar (the typical naming pattern for a test method), plus a lot test-related terminology such as "assertion" and "verification") which leads some people to believe that it actually does have something to do with tests. So, some smart people said: "Hey, let's just change the name" to remove any potential for confusion.

And that's what BDD is. It's just TDD with any test-related terminology replaced by examples-of-behavior-related terminology:

  • Test → Example
  • Assertion → Expectation
  • assertshould
  • Unit → Behavior
  • Verification → Specification
  • … and so on

BDD is just TDD with different words. If you do TDD right, you are doing BDD. The difference is that – provided you believe at least in the weak form of the Sapir-Whorf Hypothesis – the different words make it easier to do it right.

Solution 2 - Testing

BDD is from customers point of view and focuses on excpected behavior of the whole system.

TDD is from developpers point of view and focuses on the implementation of one unit/class/feature. It benefits among others from better architecture (Design for testability, less coupling between modules).

From technical point of view (how to write the "test") they are similar.

I would (from an agile point of view) start with one bdd-userstory and implement it using TDD.

Solution 3 - Testing

From what I've gathered on Wikipedia, BDD includes acceptance and QA test that can't be done without stakeholders/user input. Also BDD uses a natural language to specify its test while TDD usually uses programming language. There might be some overlap between the two but I think it's not the vagueness but BDD's language that is the main difference.

As for where you are to start, well that really depends on your development process, doesn't it? I assume if you are doing bottom-up that you're going to write TDD first and once you reach higher level you'll use BDD to test if those features work as expected.

As k3b noted: main difference would be that BDD is problem-domain oriented while TDD is more oriented solution-domain.

Solution 4 - Testing

Just copying the answer from Matthew Flynn which I agree more than "TDD and BDD have nothing to do with tests":

Behavior Driven Development is an extension/revision of Test Driven Development. Its purpose is to help the folks devising the system (i.e., the developers) identify appropriate tests to write -- that is, tests that reflect the behavior desired by the stakeholders. The effect ends up being the same -- develop the test and then develop the code/system that passes the test. The hope in BDD is that the tests are actually useful in showing that the system meets the requirements.

UPDATE

Units of code (individual methods) may be too granular to represent the behavior represented by the behavioral tests, but you should still test them with unit tests to guarantee they function appropriately. If this is what you mean by "TDD" tests, then yes, you still need them.

Solution 5 - Testing

BDD is about getting your TDD right. It provides "structure and diciplene" to your TDD. It guides you in testing the right thing and doing the right amount of test. Here is a fantastic small post on BDD and TDD,

http://codingcraft.wordpress.com/2011/11/12/bdd-get-your-tdd-right/

Solution 6 - Testing

A fantastic article on the differences between TDD and BDD:

http://www.lostechies.com/blogs/sean_chambers/archive/2008/12/07/starting-with-bdd-vs-starting-with-tdd.aspx

Should give you everything you need to know, including problems with both, and examples.

Solution 7 - Testing

Terminology are different, but in my work, i use TDD to dev detail, mainly for unit test, and the BDD is more high level, for customer, QA or no-tech man .

Solution 8 - Testing

I think the biggest contribution of BDD over TDD or any other approaches, is making non-technical people(product owners/customers) part of the software development process at all levels.

Writing executable scenarios in natural languages have almost bridged the gap between the requirement and the delivery.

Product owners can himself run the scenarios he had written and test with different data sets if he wants to play around the behavior of the code written by the development team.

That's amazing! Customer is sitting right at the center and precisely not just asking what he really wants but verifying and experiencing the deliverables as well.

Solution 9 - Testing

The main difference is just the wording. BDD uses a more verbose style so that it can be read almost like a sentence.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJon AbacaView Question on Stackoverflow
Solution 1 - TestingJörg W MittagView Answer on Stackoverflow
Solution 2 - Testingk3bView Answer on Stackoverflow
Solution 3 - TestingDaniel FathView Answer on Stackoverflow
Solution 4 - TestingqxlabView Answer on Stackoverflow
Solution 5 - TestingAnshumanView Answer on Stackoverflow
Solution 6 - TestingMark MayoView Answer on Stackoverflow
Solution 7 - TestingHuanView Answer on Stackoverflow
Solution 8 - TestingDhananjayView Answer on Stackoverflow
Solution 9 - TestingRahul GargView Answer on Stackoverflow