Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TDD and BDD Differences

Tags:

tdd

testing

bdd

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?

like image 662
Jon Abaca Avatar asked Dec 09 '10 06:12

Jon Abaca


People also ask

What is better BDD or TDD?

BDD has the edge over TDD in communication and feedback. Since the behavior descriptions in BDD are given in plain, descriptive English, your clients can understand the tests so they can send feedback more quickly.

What is difference between TDD and BDD and ATDD?

The TDD approach focuses on the implementation of a feature. Whereas BDD focuses on the behavior of the feature, and ATDD focuses on capturing the requirements. To implement TDD we need to have technical knowledge. Whereas BDD & ATDD do not require any technical knowledge.


2 Answers

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.

like image 189
Jörg W Mittag Avatar answered Oct 04 '22 05:10

Jörg W Mittag


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.

like image 22
k3b Avatar answered Oct 04 '22 07:10

k3b