DEV Community

Hash
Hash

Posted on • Edited on

2 1 1 1 1

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:

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

SurveyJS custom survey software

JavaScript Form Builder UI Component

Generate dynamic JSON-driven forms directly in your JavaScript app (Angular, React, Vue.js, jQuery) with a fully customizable drag-and-drop form builder. Easily integrate with any backend system and retain full ownership over your data, with no user or form submission limits.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay