When we are planning to start our
automation framework design using JAVA or any programming language, there is a lot of buzzes
and confusion around what exactly unit testing, Test-Driver Development (TDD) and Behaviour
Driver Development (BDD) is, which approach is best to follow and what actually is
difference between these approaches. Let’s Check it out.
Unit
Testing
Unit Testing is normally done to test each and every single functionality, for this developers create a unit test to test each
function one by one, Unit Testing is usually done so that developers can catch their
own bugs and it existing code should not break after adding any new code to it. Needless
to say, this test should be easy, small, simple and quick to write and execute.
Test
Driven Development (TDD)
Test-Driven Development
starts with designing and developing tests for every small functionality of an
application. In the TDD approach, first, the test is developed which specifies and should validate what the code will do.
In this Testing process, we first write the code and then test. Tests might fail since tests are developed even before the development. In order to pass the test, the development team has to develop and refactors the code. Refactoring a code means changing some code without affecting its behavior.
Test-Driven development is a
process of developing and running automated test before actual development of
the application.
In Short TDD approach looks
like this
Behavior
Driven Development (BDD)
BDD is a way to deliver requirements. But not just any
requirements, working ones. With BDD, we write scenarios in a format that can be run against the software to
ascertain whether the software behaves as desired. BDD is the logical next step
up from Test-Driven Development (TDD).
All the Scenarios are written in Gherkin language which
uses Given, When, Then, And.
Here, Given indicates
the initial context, When indicates the occurrence of an
interesting event, and Then asserts an expected outcome. And maybe used to in place of a repeating keyword, to make the scenario more readable.
With the Help of Gherkin, we can write any requirements in a detailed format.
For instance
Given My Account has 1000 Rs as Balance, when I withdraw
500 Rs from that, my remaining balance would become 500 Rs.
In Practice, BDD Approach looks like this.
Image Source :Google
Hi, its very nicely written blog. Very Informative. I have also written something about it. Have a look.
Replyhttps://www.fleekitsolutions.com/bdd-vs-tdd-pros-cons/