Thursday May 23, 2019
TDD is very useful to guarantee a quality code, but it is always possible to go a step further, and that is why the BDD Behavior Driven Development was born.
Driven development behavior (Behavior Driven Development) uses concepts of DDD (Domain Driven Design) to improve the focus of TDD.
BDD is the answer that Dan North gave to the difficulties presented by TDD. One of the reasons for blocking documented in his article Introducing BDD was the fact of calling the tests “test”.
This leads to the erroneous consideration that the mere fact of conducting tests means that the application is well done.
North introduced the concept of “behavior” to replace the “test”, and the change solved many of the doubts that arose when applying TDD. Soon after, in 2003, it would launch JBehave, the first BDD framework, based on JUnit.
The BDD tests are written in an almost natural language, where the keywords that define the process that gives value to the user prevail. A BDD test looks similar to the following:
Scenario: Add a product to the shopping basket
Given I am viewing the article page
When I click the “add to cart” button
Then the shopping cart counter increases
And the item appears in the shopping cart
The keywords in orange are the ones that BDD tools like JBehave, Cucumber or behave interpret.
The test cases are scenarios (Scenario), which have an initial status (Given), one or more actions of our own test (When) and consequences to prove (Then).
If there are more actions of a specific type, we will connect them with an And.
The scenarios are defined in flat text files (features), which are easily readable by all parties.
The concrete implementation of the steps that are defined in these scenarios is done in the steps files, where the programmers are responsible for scheduling the actions that they want to try to perform.
BDD makes it easier for the developer to determine the scope of their tests; it is no longer about testing methods or classes, but about ensuring that functionality behaves as the user expects.
Another of the main advantages of BDD is the use of language that all the interested parties can understand with minimum training, without having previous knowledge of programming.
Thanks to this, all parties involved in the development of a product can understand what is being worked on and what is the functionality involved.
When a BDD test fails, the entire team is able to identify the component that is failing and can contribute ideas to the conversation, where they all add up.
The BDD also allows designing the product tests around the domain and performing tests that effectively add value to the end user.
The BDD tests know the application the same as the user, and therefore force all the teams to work by functionalities and behaviors of the application, without forcing a concrete organization of the code internally.
Finally, another advantage of BDD is that it allows reusing a large part of the test code, since the common steps of the tests (login, click on a button …) can be standardized and re-used several times.
Behavior-driven development gets hold of uncertain user stories and acceptance criteria and converts them into a proper set of options as well as examples that may be wont to generate documentation, automatic tests, and a living specification.
In alternative words, it gets everybody on a constant page and ensures that there’s no miscommunication concerning however the software system behaves or what price it provides to the business.
At very least, BDD is value vie nearly any software system project that needs input from stakeholders and business folks.
It’s an excellent thanks to dramatically curtail on the waste that’s generally seen in software system comes whereas guaranteeing that they’re delivered on time and on a budget instead of changing into a data point.
The tests that you simply write also will be loads of additional intelligible and purposeful to everybody on the team.
Imagine a long software system project that your team recently completed.
However long did it take from origin to delivery? Currently, imagine that you simply may do a constant project over with everything unbroken the same—except your team would grasp everything they learned throughout the initial project.
However long would the second project desire complete? The distinction between these 2 eventualities tells you that learning is that the constraint in software system development.
Deliberate discovery is that the initiative in behavior-driven development: Learning as quickly as potential to get rid of the constraints on a project to deliver on time and on budget.
What is Deliberate Discovery?
Most software system development groups’ are acquainted with user stories and acceptance criteria.
As an example, a user story for Twitter could state that a user will reply to a different user’s tweet.
Acceptances criteria facilitate outline the specifics of however that practicality is going to be enforced, like the presence of a reply button on the primary user’s profile.
The matter is that these 2 tools—user stories and acceptance criteria—never explore any unknowns.
The deliberate discovery means having conversations regarding user stories and acceptance criteria victimization concrete examples—and presumptuous content.
As an example, a user would possibly ask: can my reply seem in my Twitter feed for anyone to see? The initial user story and acceptance criteria might not have such the solution thereto question, however, it might clearly have an enormous impact on the design of the general application.
Rather than building software system and golf shot it before of users to induce feedback, the goal of deliberate discovery is to undertake and learn the maximum amount as potential before writing any code to reduce waste and maximize productivity.
Who ought to be involved?
Deliberate discovery processes ought to involve as many alternative team members as you would like to supply insights into their specific areas of experience.
Developers might imagine of options on a really technical level, whereas domain specialists could have insights into what actual customers square measure searching for in terms of practicality.
All of those insights square measure crucial for reducing the uncertainty around options and ultimately meeting the software’s business goals.
Some samples of team members to incorporate are:
Getting in the correct mental attitude
Team exercises square measure an excellent thanks to getting everybody within the right mental attitude for future deliberate discovery conferences.
Liz Keogh suggests one common exercise that works best in little teams of 3 or four folks in an exceedingly dedicated meeting space with a whiteboard.
The exercise will commence by drawing four columns on a whiteboard:
Also Read : How To Choose The Best Test Management Service
Story Column: all and sundry ought to tell a story a couple of drawbacks they need to be encountered and a discovery they created to resolve the matter.
Commitment Column: What choices were created that solid the problem as an example, choices concerning deadlines or writing the incorrect code?
Deliberate Discovery: may you have got discovered data earlier that may have LED to a unique decision as an example, speech customers or emotional early.
Real choices Column: however may you have got unbroken your choices open longer as an example, creating a commitment later once additional data was on the market?
After finishing the exercise, the team ought to discuss however adding the invention method may facilitate them to establish and avoid the issues.
The takeaway ought to be that creating the invention early usually prevents the matter from happening within the 1st place.
BDD is a powerful tool capable of generating real value for the user by focusing the tests on the final product as a whole and not on the code.
If you decide to take the step and try it, you will see how BDD can be your best ally in software development.