TDD, BDD and ATDD

Damla Mutlu
Delivery Hero Tech Hub
3 min readApr 11, 2022

Learn both test approaches, compare differences between them and decide which one is suitable for your project.

Test-Driven Development — TDD

Test-driven development is a software development approach which is based on writing test before code and design production code depending on the test. Sometimes it is called as red-green test.

Process of TDD :

  1. Write test.
  2. Run the test. Both tests will fail because there is no implemented code. RED
  3. Write just enough implementation code to make the test pass.
  4. Run the test again. Tests will pass. GREEN
  5. Refactor.
  6. Repeat.

The refactoring step is just for cleaning code and improving code quality. There is no update for main functionality or behavior. Until all tests pass, the process is repeated.

Before writing a test, developers should analyze needs and understand code behavior. Moreover, This technique attempts to test conditions of code. That means the test should cover both lines of code. Also, It is very popular in the agile development ecosystem.

Benefits of Test-Driven Development :

  • Helps reduce time for refactoring.
  • Helps explore bugs and errors very quickly.
  • Helps get faster feedback to resolve issues.
  • Encourages the development of cleaner and better design.
  • Enhances the productivity of the programmer.
  • Creation of extensive code that is flexible and easy to maintain.

Behavioral-Driven Development -BDD

Behavioral-driven development is a testing approach which has been created from TDD. BDD attempts to test system behavior. This approach defines various ways to develop a feature based on its behavior. The most popular approach is Given-When-Then that is used for writing test cases.

This approach includes three phase. First phase is Given, which is to give inputs of the test. Second phase is When, which represents triggering time of an event or action. Last phase is Then, which is an output of the test.

Benefits of Behavioral-Driven Development :

  • BDD reaches wide range of stockholders because of non-technical language. According to this approach, requirements are more understandable for all tech and non-tech teams.
  • Focuses on system behavior from perspective of customers and developers.
  • Provides several ways to illustrate real-world scenarios for understanding requirements

Acceptance Test-Driven Development — ATDD

Acceptance test-driven development is a testing approach which is written from user’s perspective as an acceptance. It is similar with behavioral-driven test. It is used non-technical language and it acts as an integration test. ATTD attempts to test that the code working as expected.

This technique enhances collaboration among developers, users and QAs for defining acceptance criteria. ATDD can be considered a teamwork. The following methods are used for applying ATTD:

  • Analyzing real-world scenarios.
  • Deciding acceptance criteria for test scenarios.
  • Focusing on development according to accepted test cases.

Benefits of Acceptance Test-Driven Development :

  • Analyzing requirements very clearly.
  • Enhancing communication between users and developers, QAs.
  • Providing a guide for the entire development process.

Differences Between TDD, BDD and ATDD:

--

--