What are the primary differences between TDD and BDD?

NotMyself picture NotMyself · Aug 5, 2008 · Viewed 43.1k times · Source

Test Driven Development has been the rage in the .NET community for the last few years. Recently, I have heard grumblings in the ALT.NET community about BDD. What is it? What makes it different from TDD?

Answer

Christian Lescuyer picture Christian Lescuyer · Aug 5, 2008

I understand BDD to be more about specification than testing. It is linked to Domain Driven Design (don't you love these *DD acronyms?).

It is linked with a certain way to write user stories, including high-level tests. An example by Tom ten Thij:

Story: User logging in
  As a user
  I want to login with my details
  So that I can get access to the site

Scenario: User uses wrong password

  Given a username 'jdoe'
  And a password 'letmein'

  When the user logs in with username and password

  Then the login form should be shown again

(In his article, Tom goes on to directly execute this test specification in Ruby.)

The pope of BDD is Dan North. You'll find a great introduction in his Introducing BDD article.

You will find a comparison of BDD and TDD in this video. Also an opinion about BDD as "TDD done right" by Jeremy D. Miller

March 25, 2013 update

The video above has been missing for a while. Here is a recent one by Llewellyn Falco, BDD vs TDD (explained). I find his explanation clear and to the point.