TDD and BDD: The Ultimate Answer to Life, the Universe, and (Testing) Everything

Writing Your Tests First

Historically in software, we code up a bunch of functionality, get a prototype going, maybe showcase it a few times, add a few more features, rush towards an initial release, and somewhere along the way we push in some automated tests.

  • When you’re done, you’re submitting both features and tests with the same work order — no need to procrastinate, testing is already done !
  • Since you’re deliberately thinking about testing early on, you will (hopefully) come up with more and better test scenarios.
  • As this practice takes hold, you’re encouraging a test and quality oriented team culture.

The Business Philosopher

I’ve seen BDD translated as both “Business Driven Development” and “Behavior Driven Development”. For my purposes, the terms are synonymous. We are talking about the behavior of customers and users as it relates to code for a business, or business use cases. So, either translation works for me.

Feature: Donuts
Scenario: Glazed donuts
Given I make a fresh run of donuts
When I add glazing
And I serve to customers
Then customers are ecstatic
Scenario: Whole Wheat Vegemite donuts
Given I make a run of whole wheat sugar free donuts
When I add vegemite
And I serve to customers
Then customers burn down my bakery

What is my framework if it’s not BDD or TDD ?

We have a term “waterfall” to describe something not Agile. What about automated tests ? If we aren’t using TDD or BDD — if we aren’t writing tests first, and we aren’t using Cucumber specs as our test engine — what do we call this ?

What’s the difference ? Why is there a difference ? Can you do both ?

TDD is a process which writes automated tests before application code. BDD is an approach which incorporates your work specification, as the top layer of your test execution stack.

Wrapping up: Tech stacks come and go, but Fundamentals rarely change

Clearly, your author is a fan of both TDD and BDD. That said, fundamentals of software quality don’t change much. We need to be well-organized, we need to track execution, we need to be proactive, think outside the box and anticipate problems.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Add Lightness | Better Testing, Better Software

Add Lightness | Better Testing, Better Software

26 Followers

A software dev in test thinking against the grain. “To go faster, simplify, then add lightness.” ~Colin Chapman #cleancode #minaswan #innovate