We have come across a number of clients interested in understanding more about TDD (Test Driven Development) and BDD (Behaviour Driven Development). What benefits do these related approaches bring to project delivery? Who should carry them out? What competencies are required? Which one is better?
Firstly, TDD is a software development approach that relies upon writing automated tests first and then building the code to pass those tests. The tests will keep failing until the minimum code is written to pass those tests. Advantages are that code is developed to focus on passing tests, and does not stray to un-needed functionality, hence it’s lean. Code that passes can be refactored (improved or hardened without changing the outcome) later. The trick is to write the correct test scripts. Since using TDD is within the coding domain, it is usually the concern of the coder.
BDD is a tool a Business Analyst or Agile team can use with stakeholders to tease out the desired system behaviours covering various circumstances or eventualities. Using a BDD approach helps the team and stakeholder talk through, visualise and document how the system should behave. It is increasingly used by Agile teams to help develop User Stories to a richer dept at the appropriate time. Once the desired behavioural functionality has been teased out, a clearer picture of what’s needed can be communicated to the rest of the team. Since the kernel of the work done, in a BDD exercise, is achieved through a workshop approach with stakeholders, it is usually the domain of the Agile team members who interact with the business – using facilitation, active listening, communication and investigative qualities (typical of an Agile BA).
TDD and BDD, while seemingly related, are actually used in very different scenarios and by people with different skill sets and responsibilities.
Example using BDD writing convention – (Given, When, Then)
Scenario 1
Given: The customer has an outstanding balance
When: Today’s date is after the due date
Then: Present the customer with a ‘Please pay now’ message on next login
Scenario 2
Given: The customer has an outstanding balance
When: Today’s date is less than 30 days before the due date
Then: Present customer with a message on login that due date is approaching within the next 30 days
Scenario 3
Given: The customer has an outstanding balance
When: Today’s date is more than 30 days before the due date
Then: Present the customer on login with a promotional discount if they settle their account early