top of page

Basics of TDD and BDD

TDD stands for test driven development. It is a software engineering practice in which developers write new code only if automated test has failed. In other words, test cases for each functionality are created and tested first, if the test fails then the new code is written in order to pass the test which makes coding simple and bug-free. This also avoids duplication of code.

TDD Cycle -

  1. Write a test

  2. Make it run

  3. Change the code to pass the test which is called refactoring

  4. Repeat the process

Now let's talk about BDD

Behaviour Driven Development (BDD) is a practice stemming from Test Driven Development (TDD). It is an Agile software development methodology in which an application is documented and designed around the behavior a user expects to experience when interacting with it. By encouraging developers to focus only on the requested behaviors of an app or program, BDD helps to avoid bloat, excessive code, unnecessary features or lack of focus. BDD uses DSL (Domain Specific Language) I.e Gherkin, a formal language for capturing software requirements. It makes use of a set of keywords. The best known of these are the Given/When/Then triplet that is used to describe each test scenario.

For example:

Scenario − Withdraw money from account.

  • Given I have $100 in my account.

  • When I request $20.

  • Then $20 should be dispensed.

Benefits of Using Gherkin:

There are many advantages of using Gherkin language to write and define the behaviour in your BDD framework. Some of the major ones are mentioned below: 1. Gherkin is simple

2. Increases code reusability

3. Focuses on project requirements

Disadvantages of Using Gherkin:

Every tool and software has some limitations and disadvantages and Gherkin is no different about it. Here are some of the cons of using Gherkin: 1. Not for all projects

2. Potential Expense

3. It requires a lot of engagement


Thus, BDD has been bridging the gap between developers and business for more than a decade now and has been quite successful in making the implementation as close to the behaviour as possible.


48 views0 comments


Mit 0 von 5 Sternen bewertet.
Noch keine Ratings

Rating hinzufügen
bottom of page