Kirill Buga
JS developer
25.04.2014
First of all we should define BDD (Behavior Driven Development) and how to distinguish it from TDD (Test Driven Development). TDD is - an approach, which basically means writing module tests for application. The tests are created before the code is written, and this is an obstacle for some developers, because testing something non-existent is difficult.
BDD is development technic that is widely used in Agile along with TDD. It is based on behavioral system’s aspects, while TDD is based on implementation aspects. While using the BDD we reduce to minimum possibility of misunderstanding among users, developers and business-analytics. We can achieve this by creating Executable Scenarios (scenarios described in the specifications are translated into executable tests).

BDD is neither new nor revolutionary, it is just a farther evolution of TDD-approach, where instead of “test” we use “must” word. Leaving words aside, we can expect using term “must” more naturally than “test” in implementation process. If we think in terms of “functionality”, this would lead us to classes, written for specification validation and could be the efficient implementation instrument.
Let’s go back to UserStory template. Its classical representation is as follows:
As a [1]
I want [2]
so that [3]
where [2] – functionality, [3] – benefit, supported by [2], [1] – person, who achieves this benefit.

The value of current approach lies in possibility to eliminate misunderstandings, both from developers’ and analytics’ side, regarding concrete system’s features and components. To define whether system behavior is correct or not, we introduce so-called history’s approve criteria. This pattern should be flexible enough to stay uncomplicated for users and analytics but still well-structured enough to be dividable into the parts. For this template, we can use the next form:
(Given) set of Pre-conditions,
(When) when an event occurs,
(Then) outcome is achieved.

Let’s look at such example:
Given: I am an admin user
When: I entered my credentials
And pressed “Enter” button
Then I should be logged in
And see the admin page
Scenarios, implemented according to this template could be used as test-cases. Moreover, the main advantage of this approach is easy-to-read format, not only for technicians, but also for users, busyness-analysts, testers and managers and thus helps to improve the understanding-level.

World around us is moving forward very quickly. Spheres of business and development have need of direct communication more often. BDD is the approach that helps them find common language. In the next article, we will examine Specflow - .net project for implementing scenarios, described earlier.
1. http://dannorth.net/introducing-bdd/
2. http://habrahabr.ru/company/etnasoft/blog/166747/
3. http://habrahabr.ru/post/139674/
Author:
Kirill started programming career with .Net, but later fell in love with JavaScript. He is vocal about his software ideas and enthusiastically tackles every assignment.
He is friendly, easy to get along with, liked by clients and respected by his co-workers.
Kirill «hates» Apple devices, that’s why he recently bought MacBook in order to prove that.
Enjoyed this article?
you might want to subscribe for our newsletter to get more content like this: