Behavior-driven development (BDD) is an agile software development method centered around collaboration between business and IT professionals that have a stake in finding a solution for a complex problem. The core objective is to achieve a shared understanding of the problem. BDD involves use of a domain-specific language (DSL) using natural-language constructs (e.g., English-like sentences) that can express the behavior and the expected outcomes. BDD encourages collaboration among developers, quality assurance experts, and customer representatives in a software project. It encourages teams to use conversation and concrete examples to formalize a shared understanding of how the application should behave. BDD is considered an effective practice especially when the problem space is complex. A common misconception regarding BDD is that it supposedly is a refinement of test-driven development (TDD). While it was originally derived from TDD practices, the sole purpose of BDD is to gain a shared understanding of the problem space and find a way to write this down in a Business Language, using Real data, whilst being Intention revealing, Essential and Focused (BRIEF). BDD combines the techniques of TDD with ideas from domain-driven design and object-oriented analysis and design to provide software development and management teams with shared tools and a shared process to collaborate on software development. At a high level, BDD is an idea about how software development should be managed by both business interests and technical insight. Its practice involves use of specialized tools. Some tools specifically for BDD can be used for TDD. The tools automate the ubiquitous language.
Overview BDD is a process by which DSL structured natural-language statements are converted into executable tests. The result is executable specification eventually forming Living Documentation: Requirements that are also the first acceptance tests that drive your software development (Acceptance test-driven development). BDD focuses on:
Collaboration between business and technical people Creating a shared understanding of the problem that needs solving and how to solve this (without including any details on a chosen technical implementation yet) Writing this down in an unambiguous, precise way so that it can become executable specifications Starting from this point, many people developed BDD frameworks over a period of years, finally framing it in terms of a communication and collaboration framework for developers, QA and non-technical or business participants in a software project.
Principles BDD suggests that software tests should be named in terms of desired behavior. Borrowing from agile software development the "desired behavior" in this case consists of the requirements set by the business — that is, the desired behavior that has business value for whatever entity commissioned the software unit under construction. Within BDD practice, this is referred to as BDD being an "outside-in" activity. TDD does not differentiate tests in terms of high-level software requirements, low-level technical details or anything in between. One way of looking at BDD therefore, is that it is an evolution of TDD which makes more specific choices.
Behavioral specifications Another BDD suggestion relates to how the desired behavior should be specified. BDD suggests using a semi-formal format for behavioral specification which is borrowed from user story specifications from the field of object-oriented analysis and design. The scenario aspect of this format may be regarded as an application of Hoare logic to behavioral specification of software using the domain-specific language. BDD suggests that business analysts and software developers should collaborate in this area and should specify behavior in terms of user stories, which are each explicitly documented. Each user story should, to some extent, follow the structure:
Title An explicit title. Narrative A short introductory section with the following structure: As a: the person or role who will benefit from the feature; I want: the feature; so that: the benefit or value of the feature. Acceptance criteria A description of each specific scenario of the narrative with the following structure: Given: the initial context at the beginning of the scenario, in one or more clauses; When: the event that triggers the scenario; Then: the expected outcome, in one or more clauses. BDD does not require how this information is formatted, but it does suggest that a team should decide on a relatively simple, standardized format with the above elements. It also suggests that the scenarios should be phrased declaratively rather than imperatively — in the business language, with no reference to elements of the UI through which the interactions take place. This format is referred to in Cucumber as the Gherkin language.
… excerpt ends here. Continue reading the full article.