BDD Vs TDD
Amit Kumar Tiwari
Head of Salesforce Architecture & Practice | Delivering largest Salesforce Implementation for Wealth | Architect Leader | FinTech | Design Thinker | DevSecOps Advocate | Salesforce SME | AgilePM | Open-Source Evangelist
BDD Vs TDD – The two important Quality Engineering Practices!
The force to agile approach shift in software development over the past few years has lead in an era of continuous testing and change. This new approach in “quality engineering” has made the development process more dynamic, which in-results equipped team with the ability to introduce new changes, prevent bugs/ breakdowns from slow-down the scalability of applications. That’s why for anyone operative in the agile development environment, there is a need to be familiar with two important Quality Engineering Practices – Test-Driven Development (TDD), and Behaviour-Driven Development (BDD).
Well, I think the only logical way to begin is – knowing the first step to solve any problem, which is nothing other than truly understanding the problem we are trying to solve.
And that’s what we are going to do now. It’s important to know – ‘What are we testing for?’ Are we testing to figure out the behaviour of the application? Or, are we more interested in the implementation? These are few of the great questions to ask.
BDD is designed to test an application's behaviour from the end user's standpoint, whereas TDD is focused on testing smaller pieces of functionality in isolation.
In both cases, the developer writes the test before writing the code to make the test pass.?
Most of us are quite familiar with TDD; it’s been widely adopted by Agile development firms, and there are many different tools to help teams to get ready with this.?
TDD typically involves running the test to see it fail, and then writing the code to make the test pass.?We repeat this Red-Green-Refactor loop over and over until we have a complete feature.
TDD - is the code valid?
On the other hand, BDD is often misunderstood. And, since it involves communication between business and technical teams – there are limited available tools.
领英推荐
BDD involves a developer, test engineer?and?a product owner (and potentially other stakeholders) who collaborate to come up with?concrete examples?of acceptance criteria in a user story.?The key to BDD is to get the specifications from the user to test the system’s behaviour.?There is a high level of communication before any implementation to provide a greater level of confidence.
BDD - Given-When-Then?
Since the two terms BDD and TDD have wide spectrum of similarities (test-first approaches) with similar sounding; it’s easy to confuse one for the other, or treat them to be synonymous, right? However, the processes are markedly different. The key difference is the scope. TDD is a?Development Practice,?while BDD is a?Team Methodology.?
It’s important to understand that BDD and TDD aren’t mutually exclusive — For example, a development team may use BDD to come up with higher level tests that confirm an application's behaviour. When implementing the specifics, developers may create separate unit tests to ensure the robustness of the components, since these components may be reused elsewhere across the application.
The Bottom Line
TDD has become the default approach for Agile software development over the past several years. BDD represents an evolution beyond TDD, where business goals can be better communicated to development team by bridging the gap between business and technical teams. BDD helps reduce any confusion about acceptance criteria / desirable functionality, identify potential problems early with user stories, and ensure that the application functions as expected for end users.
The Bottom line – BDD has the edge over TDD in communication and feedback!?
So, TDD or BDD?
The real answer is both. We need Developer Tests for the fast feedback, and we want User Tests to ensure that the features are built to the user specs.
Can BDD and TDD Work Together? – YES,
Debugging the errors in the latter stages of the development life cycle?often proves very expensive. In most cases, ambiguity in understanding the requirements is the root cause. One needs to ensure that all the development efforts remain aligned toward fulfilling pre-determined requirements.?
Using a Hybrid approach as a combination of both (BDD + TDD) can be helpful in this case. And it’s easier to use them together, as we don’t need to change or rework the existing practice (BDD doesn’t require reworking any existing TDD practices). All it takes is more investment in communication and building up an inclusive testing framework to accommodate the other, that can pay off in the form of less ambiguity and greater confidence in the product.
In broad terms, there are two types of bugs –
By taking the above-mentioned hybrid approach to development, we will find that TDD helps us to mitigate and avoid the first type of bugs; with BDD helping us to avoid the latter – which happen to be the most expensive to fix ??
Seasoned Technocrat of Salesforce.
2 年Commendable blog.. It gives a clear picture of how persona based functional testing can be clubbed with asserts(checks) in between to bring confidence in product quality. ?? It also helps to train alexa with "Production Release" answer. ??