What is BDD and Why?
What is BDD?
BDD (Behaviour-Driven Development) is a set of development practices that aim to reduce some common wasteful activities in software development. It simulates how an application should behave from the end user’s perspective. The main goal of implementing BDD testing is to improve collaboration between stakeholders, such as developers, testers, product managers, and business analysts. There are a bunch of frameworks that support BDD including, Cucumber, Spock, Specflow, and more.
Why BDD?
- Communication: Software development is not about the software engineers or developers only: there are Testers, PMs, POs, DevOps, and other stakeholders. BDD ensures everyone is roped in the loop right from the beginning and throughout the process, which in general fosters quality communication.
- High Visibility: BDD is explained using simple language. By using a simple language understood by all, everyone gets strong visibility into the project’s progression
- End User Satisfaction: By focusing on the business needs, you get satisfied users, which implies a happy business.
Example Code
BDD uses natural readable language (Gherkins) to describe tests that can be understood. see the example feature definition below.
Given I am on the home page
When I enter my username "myemail@gmail.com"
And I enter my password "mypassword"
Then I should see my email "myemail@gmail.com" on the dashboard
Is BDD == TDD?
There is a whole misconception about these 2 development practices but don't worry I was a victim too, till I found the truth :-).Though they are both about software development and test automation, they are not the same.TDD (Test-Driven Development) involves where writing tests before the actual code implementation. Developers use those tests to drive the development basically. TDD can be practiced at different levels of granularity, from acceptance tests to unit tests. An example could be testing a method and asserting that it returns the expected results. BDD also involves writing tests before implementation, the difference here, however, is that BDD tries the software's actual behavior from the end users' perspective. For example, When I enter my user and password and click login, what happens? This is totally from the UI point of view. BDD again uses natural language to describe tests that can be understood by non-programmers as against TDD which involves writing actual code.
Ok, so the result of our expression.
BDD == TDD = False
Below are more resources to enlighten your understanding of BDD and even TDD.