Published on and tagged with bdd  requirements

I’m currently doing my first steps with BDD (Behavior Driven Development) and Cucumber, a Ruby tool for doing BDD.

What I like about BDD is the simple, but powerful concept of Given-When-Then for specifying scenarios. It is a concept you can also use without doing BDD to specify the requirements of your application.

It simply defines the structure of how you write down the requirements in the form of scenarios (as a sidenote: in BDD, a scenario belongs to a feature. For example, a “Login” feature might consist of the scenarios “Login with username/password” and “Login with OpenID”):

Given some initial context (the givens),
When an event occurs,
Then ensure some outcomes.


“Given” defines the preconditions, “When” defines what happens, and “Then” defines the result of the scenario. Or in other words: “Given” describes the start state, and “When” the steps necessary to reach the accepting state (= “Then”).

A simple example of a “Publish new article” scenario might look like:

Given I am logged in
When I write an article with the title "My article"
And I publish the article
Then I should see the message "Article published"
And the article "My article" should appear on the homepage

The simplicity of this format makes it easy to discuss the requirements of your application. And thanks to tools like Cucumber you can even make such specifications executable, but that’s something for another post…

9 comments baked

© daniel hofstetter. Licensed under a Creative Commons License