So what’s the different between Test-Driven Development (TDD) and Behavior-Driven Development (BDD)? I’ve written about that before, but I think that post lacks something more illustrative.
For one thing, I forgot to mention: I’m in the camp that thinks of the last D as design, instead of development. That matters.
I’ve heard developers say things like:
- “I don’t do TDD anymore, now I’m BDD all the way!”, or
- “I only do TDD, because I can’t use Cucumber, SpecFlow, or any one of those BDD tools.”
Here’s how I see it…
At some point, I learned to write unit/integration tests in this manner:
Through TDD, I learned to write such test before writing the actual code.
Then I learned about “BDD-style” tests, so I refactored tests such as the one above into the one below:
That was my transition from Arrange-Act-Assert (AAA) to Given-When-Then (GWT).
Then I learned that BDD and TDD go hand-in-hand:
No special tools, languages, test frameworks. In the example above, just plain C# and xUnit.net.
- BDD specifying the desired outcome
- TDD specifying the desired approach to achieve the desire outcome