Home Navigation

Friday 27 October 2017

What is BDD? TDD vs BDD

What is BDD?

BDD emerged from the process known as test-drive development (TDD). The concept behind BDD is to provide development and management teams with a shared process and tools to collaborate effectively while developing software. The developers wrties scenarios using Gherkin ( Ubiquitous language) and get feedbacks from the stakeholders.

Unit tests often help to reveal "small and stupid" mistakes in the code. The absence of unit tests would make me worry about underlying quality. When my unit test fails, I can quickly find the cause of this failure (at least, I know what part of my code contains a mistake). When my behavioral test fails, I sometimes need a little of debugging to find the cause. Also behavioral tests tend to cover "happy paths" (there is a tendency to miss them out) only. But they're the most useful when we need to refactor an old system with tons of legacy code, so... I think, TDD and BDD are like left and right hand for right-hander: you use your right hand more often and its fine motor skills are better, but it's kinda difficult to live without a left hand, too.

TDD vs BDD

TDD:

  • Focus: TDD is an "inside-out" process, the focus is on quality
  • Mostly written by developers
  • Specificity: When I test a spark plug in isolation - and the test fails - I know that spark plug is faulty. When a Unit Test fails, you know exactly what has failed.
  • Speed: A Unit Test is a test of a component in isolation. This may require mocking of (potentially slow) external dependencies. As a result, Unit Tests are super-quick to run.
  • 100% code coverage is a rare/difficult
  • Write to test each unit of codes, functions, class
  • Design to test low level scenarios

BDD:

  • Focus: BDD is an "Outside-in" process. The focus is on value.
  • Who writes the tests? The plain English format means that the tests can be written by the person that understands the customer best: the Product Owner. Who reads the tests? Almost anyone: Developers, Testers, Stakeholders, Business Owner, Product Owner.
  • Specificity: When my motorbike doesn’t start, I know that something is wrong. But I don’t know what is wrong.
  • Speed: Behavioral Tests are tests of the system as a whole. The system must be “put into a known state” before each and every test. Not particularly difficult to do… but not quick either.
  • 100% code coverage is not uncommon
  • Design high level scenario to test expectation from software or workflow
  • Design normally for acceptance testing or testing automation
  • Communicational pattern like examples 
  • Solves cost of translation
Ref: http://www.DevelopmentThatPays.com

No comments:

Post a Comment