Book Image

Instant Cucumber BDD How-to

By : Wayne Ye
Book Image

Instant Cucumber BDD How-to

By: Wayne Ye

Overview of this book

<p>Cucumber is a Behavior Driven Design framework, which allows a developer to write specification tests which then tests that the program works as it should. It is a different development paradigm, as it involves writing what the program should do first, then you develop until it passes the tests.<br /><br />Instant Cucumber BDD How-to will cover basics of Cucumber in a Behaviour Driven Development (BDD) style and explain the essence of Cucumber, describe how to write Cucumber features to drive development in a real project, and also describe many pro tips for writing good Cucumber features and steps. Cucumber is a very fun and cool tool for writing automated acceptance tests to support software development in a Behaviour Driven Development (BDD) style.<br /><br />Instant Cucumber BDD How-to will highlight Cucumber's central role in a development approach called Behaviour Driven Development (BDD), describe how to write Cucumber features to drive development in a real project, and finally introduce some famous third-party libraries used inline with Cucumber.</p> <p>It will show you how to carry out all the tasks associated with BDD using Cucumber and write basic Cucumber steps. It will assist you in using Pro tips for writing expressive Gherkin and implement guidelines for writing DRY steps. You'll learn how to use Cucumber's Gherkin to describe the behavior customers want from the system in a plain language.</p>
Table of Contents (7 chapters)

Preface

Instant Cucumber BDD How-to covers an overview of Cucumber as an exciting tool to write automated acceptance tests to support software development in behavior-driven development (BDD). It elaborates the basics of TDD/BDD and explains the essence of Cucumber, describes how to write Cucumber features to drive development in a real project, and also depicts many pro tips for writing good Cucumber features and steps. Finally, it introduces some famous third-party libraries used inline with Cucumber.

What this book covers

Understanding behavior-driven development (Intermediate) introduces the concept of TDD and BDD, and explains the benefits of using BDD in software development.

Setting up an environment for Cucumber BDD on Rails (Intermediate) describes how to set up a Cucumber BDD environment based on Rails, and explains what Cucumber is and the typical process of using Cucumber in BDD.

Writing your first Hello World feature (Simple) provides an example for driving a simple "Hello World" feature using Cucumber.

Learning foundation knowledge and skills (Intermediate) explains the basic Cucumber knowledge for writing features and step definitions.

Building a real web application with Cucumber (Intermediate) shows how to use Cucumber to behaviorally drive a real Rails application.

Mastering pro tips for writing expressive Gherkin (Intermediate) introduces many useful and handy tips for writing Gherkin.

Mastering pro tips for writing good steps (Advanced) introduces many useful and handy tips for writing DRY and maintainable step definitions.

Using third-party libraries with Cucumber (Intermediate) introduces several great Ruby gems to support BDD using Cucumber better.

What you need for this book

You will need the following software to follow the recipes in this book:

  • Ruby Version Manager (rvm)

  • Ruby version 1.9.3

  • Rails version 3.2

  • The latest version of Cucumber

  • A handy text editor (Vim or Sublime Text)

Who this book is for

This book is for the agile software development team that wants to adopt a behavior-driven process using Cucumber. It assumes that the team is passionate about reducing communication gaps between developers and product managers, ensuring that the development is always on the right track and always focuses on the minimum marketable value.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "By running this, Cucumber will initialize a folder called features into your Rails project."

A block of code is set as follows:

Feature: Write blog
As a blog owner 
I can write new blog post
  Scenario: Write blog
    Given I am on the blog homepage
    When I click "New Post" link
    And I fill "My first blog" as Title
    And I fill "Test content" as content
    And I click "Post" button
    Then I should see the blog I just posted

Any command-line input or output is written as follows:

$ \curl -L https://get.rvm.io | bash -s stable --ruby f

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "And then after clicking on the Go button, we will see the search result."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.