DEV Community

Hash
Hash

Posted on • Updated on

TDD vs BDD

Since Agile development involves continuous change, testing has become invaluable to prevent these frequent changes from introducing new bugs or breaking the app.

Most developers are familiar with testing approaches, in this short article, we will look at TDD and BDD and explore the differences:

TDD

  • TDD stands for Test Driven Development
  • TDD is a software development methodology where tests are written before the actual code is implemented.
  • It is focused on testing smaller pieces of functionality in isolation.
  • The process starts by writing a test case
  • Might be a better approach for projects which involve API and third-party tools.
  • Although TDD is a development technique, it can also be used for CD

Test Runners: Mocha, Jasmine, Jest

Process of TDD

tdd

BDD

  • BDD stands for Behavior Driven Development
  • It is designed to test an application's behavior from the end user's standpoint
  • BDD is an extension to TDD where instead of writing the test cases, we start by writing a behavior.
  • The process starts by writing a scenario as per the expected behavior.

Test Runners: Cucumber.js, Jasmine, Jest

Example :

> Scenario: Login check
Given I am on the login page
When I enter "username" username
And I enter "Password" password
And I click on the "Login" button
Then I am able to log in successfully.

  • Might be a better approach for projects which are driven by user actions.

Process of BDD

bdd

If there are any tips to add to this short comparison, would appreciate it.

refs:

Top comments (0)