Cucumber: A Great Tool for Behavior-Driven Development

Behavior-driven development (BDD) is an approach to software development designed to start with the piece of functionality that is most important to your user by discovering what our software should do, specifying it clearly and validating that the software does and continues to do what we intend.

Cucumber logo
Cucumber is a tool to support behavior-driven development with plain-text specifications and unobtrusive automation in Ruby. We begin development of each feature with the desired new behavior, specifying that behavior with examples and making those examples executable as automated tests. After we have a failing test, we implement the behavior until the test passes.

Here is a simple set of user stories that a software developer may receive from a client or business analyst on their team.

example user stories

To demonstrate a very simple example, we will use the first user story, which calls for the ability of an administrator to view a list of blog posts.

1. Describe behavior in plain text.

example code

2. Write step definitions in Ruby.

example code

3. Run Cucumber and watch it fail.

example code

4. Write code to make the steps pass.

example code

example code

5. Run Cucumber again and see the steps pass.

example code

As you can see through this very simple example, Cucumber allows a software developer to easily translate user stories created by non-technical clients or business analysts into automated tests that can ensure the software application always behaves as expected.

For more information about Cucumber, please visit http://cukes.info, which provides a full set of documentation.

Reflections of a Project Management Intern