TDD vs BDD vs ATDD — Developers’ Methodologies to Navigate Complex Development Processes Smoothly

Jay Dwayne
7 min readSep 30, 2021

--

www.jaydwayne.com

Introduction

The last decade in the history of humanity can be easily called the technological revolution. The pandemic made it starker than ever before. The developers need to keep pace with the new languages, frameworks, tools, and processes that come into being every second.

To write code is a developer’s second nature. But, what code to write; how to write it; when to write it; and for what purpose may easily overwhelm even the most experienced and expert developers when it is raining new codes and processes day in and day out.

This constant flux can be easily navigated through the structured methodologies that focus on the task of the developers. Such methodologies anchor developers and their creations. Major development methodologies include TDD vs BDD vs ATDD, TDD stands for Test-driven Development , BDD stands for Behavior-driven Development (BDD), and ATDD stands for Acceptance Test-driven Development (ATDD).

Let us explore each in this post.

Test-driven Development (TDD)

Test-driven development method is about developing test cases before the developers start writing code. These test cases are essentially small units as per the requirements of the entire software.

The idea is to continually and consistently test the code against these test cases through the “red green refactor loop” until a stipulated unit is absolutely ready to be a part of the whole scheme.

One of the original authors of the Agile development manifesto, Robert C Martin has set forth three rules for TDD which are famously known as The Three Laws of TDD. They are:

1. You must write a failing test before you write any production code.

2. You must not write more of a test than is sufficient to fail, or fail to compile.

3. You must not write more production code than is sufficient to make the currently failing test pass.

The essence of these laws is to write the bare minimum code for the specific feature so that it passes the testing cycle successfully. The reason behind this exercise is to keep the codes clean and precise as much as possible at the unit level itself.

The best part of the TDD methodology is it allows the developers to experience the failure at the outset of the development. This helps them rule out all the possible flaws that may arise during the course of the development. And, that gets them the very exact code that is required for the exact expected software.

Major characteristics of TDD

Test-driven development promotes short development cycles for each unit to get finally added into the entire design of the software. Its major characteristics are:

· Writing of the simplest and the shortest of the code possible that passes the unit test.

· Restructuring the code that does not demand any alteration either in the functional or certain non-functional attributes of the entire software.

· Advanced planning that often saves time during coding and debugging and brings about greater customer satisfaction and better performance.

Behavior-driven Development (BDD)

Behavior-driven development (BDD) is a higher version of TDD. This method tests if all the units of the application function as per the requirement of the entire application design.

In this extended version of TDD, a higher-level test which is often called functional test is created to rule out unnecessary code writing requirements for the maximum functionality of the application.

Having written the feature-failing test, the developers then test prototypes to obtain feedback on early failure and finally write the minimum code to get the correct application function at the maximum capacity. They keep writing this code until it passes the functional test.

GWT: BDD’s syntax

The acceptance test in BDD is created by defining the user story. All the developers, testers, QAs, experts, and product managers get together to review the requirements of each user story. They brainstorm and define a certain standard of each user story that has to be fulfilled.

The team uses Gherkin language to write the examples of user stories. The domain specific language Gherkin with its specific syntax exploits this approach of GWT which stands for Given-When-Then. They are:

· Given: An actual scenario or the platform for the user to take the test, or username and password or entering of credentials by the user

· When: The actual action that the user performs or pressing of the login button by the user

· Then: The outcome of the action that the user performed in previous stage or sending the user to the home screen or the display of successful validation message.

Major Characteristics of BDD

· Emphasis on defining user stories clearly so as to fulfill the requirements of each of them.

· Reusability of the tests

· Use of non-programming language to make the code accessible to all the stakeholders in the development process.

· Focus on language and interactions.

Acceptance Test-driven Development (ATDD)

ATDD may come across as a combination of both TDD and BDD. However, the focus of this technique is on meeting the demands of users as against on getting the exact expected behaviour in the previous two techniques. This method is also called Story Test-driven Development (STDD).

The Acceptance Test-driven Development method gets together diverse stakeholders such as customers, developers, and testers. It is very important that all these stakeholders share common understanding of the user stories and their requirements in simple plain language which can be then transformed into programming language to write automated acceptance tests. For this, ATDD can draw upon BDD’s GWT approach.

Major characteristics of ATDD

· Writing of user-centric acceptance tests

· Improved communication and understanding between the teams in plain language

· Improved code quality and specific tests in business domain terms

· Facilitating quick feedback through failing tests

· Reduction in time to market

TDD vs BDD vs ATDD — a broad comparison

Each of these methods offers unique tools to the developers to make the complex development processes easier. All the stakeholders can use one of the methods or combination of them to suit their purpose. However, before adopting any of these methods of TDD vs BDD vs ATDD, it would be interesting to have a look at the broad comparison of these three.

Parameters

TDD

BDD

ATDD

Purpose

A development technique that is more concerned about individual units of an expected feature.

A development technique that revolves round expected behavior.

A development technique that focuses on satisfying user needs.

Participants

Developers

Developers, customers, QAs

Developers, customers, QAs

Preferred Language

Programming languages such as Java, Python, etc.

Gherkin / Simple English

Gherkin / Simple English

Tests

In this technique, developers write tests for developers

In this technique, it is important that tests are understood and accessible to all the stakeholders. Hence, they are written in simple English which is then transformed into automated language of tests.

This technique too calls for common language understood by all the stakeholders. Hence, use of simple English language is preferred.

Bugs

Can be easily tracked down and also their occurrence gets reduced.

Compared to TDD, it is difficult to track them down.

In ATDD too, developers may have hard time in getting them tracked down.

Suitability

Projects that do not require involvement of end users such as server, API, etc.

Projects in which user is the one who acts, such as: eCommerce sites, various types of apps.

This technique is best suited for projects where customer experiences are at the center. These are also the projects where there is much competition such as, eCommerce, apps.

Preferred Tools

JDave, Cucumber; JBehave, Spec Flow; BeanSpec; Gherkin Concordian; FitNesse; Junit; TestNG; NUnit frameworks; Selenium tool; or any open source tools.

Gherkin; Dave; Cucumber; RSpec; Behat; Lettuce; JBehave; Specflow; BeanSpec; Concordian; MSpec; Cucumber with Selenium / Serenity.

TestNG; FitNesse; EasyB; Spectacular; Concordian; Thucydides; Robot Framework; FIT.

TDD vs BDD vs ATDD : Which method to choose?

Software development is all about constant improvement and adaptability to changing requirements. These techniques ensure that the developers get enough support in this constantly changing environment. With the help of unit tests and acceptance tests, it is possible for the developers to identify the exact needs of the application and create a functional product that satisfies all the stakeholders in the development cycle.

However, this task has many challenges, the foremost being which method to choose. Also, there are other challenges like competition, deadline, inadequate skills, budget and many others. While deciding on specific testing method, following considerations can help:

· Consideration of risk factors. If an app is already functioning, introducing new features or updates may cause inadvertent crashes. In such a scenario, it is best to use a method that is averse to regression.

· It is important to have a clear understanding of the objective of the specific method. Your testing method should not only ensure that all the features are working well, but it should also ensure that the application is meeting all the business expectations that bring highest customer satisfaction.

· It is important to be compliant with the regulations of the industry. The developers and the testers need to be in the know of the rules of the land so that the end product does not suffer any legal glitches.

Conclusion

In the light of the discussion, you should choose the testing method taking into considerations all these aspects. However, you can also combine these methods instead of going for just one. For example, ATDD and TDD can be combined to achieve both collaboration and precision in the work, respectively.

Similarly, you can even borrow an aspect of one method to fit into the other. For example, BDD’s given, when, then format can very well be adapted to ATDD to define acceptance criteria of the user stories without changing the code structure.

Combination of all these three or two of these offers great possibilities for collaboration, conversations, and great insights into the specifications of the software. It results into an application that satisfies all the stakeholders involved in the development cycle. It also ensures a more efficient development environment with less errors, chaos, and uncertainty.

If you Made it to this point, Successful people look like you!

More Grace to you. My name is Jay Dwayne

www.jaydwayne.com

--

--

Jay Dwayne

As a software engineer, designer, graphic artist, guitarist, and martial artist, Jay brings a unique blend of skills and passions to every project he undertakes