Get in touch

Get in touch with Binary

Binary Studio website uses cookies to enhance your browsing experience. By continuing to use our site, you agree to our Privacy Policy and use of cookies.

Learn more more arrow
Kirill Buga JS developer 25.04.2014

BDD. SpecFlow & Watin. Part I

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 scheme by Binary Studio.png

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.

Who What Why.png

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.

BDD conditions and outcom scheme.png

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.

Developer VS QA.png

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/