A long-lived project that still receives updates
Behaviour Driven Development with elegance and joy
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
 Dependencies

Development

~> 1.1, >= 1.1.0
~> 2.1, >= 2.1.0
~> 1.2, >= 1.2.2
~> 3.35, >= 3.35.3
~> 1.12, >= 1.12.5
~> 4.21, >= 4.21.0
~> 0.14, >= 0.14.1
~> 13.0, >= 13.0.6
~> 3.10, >= 3.10.0
~> 0.21, >= 0.21.2
~> 1.7, >= 1.7.0
~> 3.4, >= 3.4.8

Runtime

~> 3.2, >= 3.2.4
~> 1.4, >= 1.4.4
~> 0.1, >= 0.1.2
~> 6.0, >= 6.0.1
~> 3.3, >= 3.3.1
~> 1.2, >= 1.2.2
~> 10.1, >= 10.1.0
~> 6.2, >= 6.2.0
~> 22.0, >= 22.0.0
~> 17.0, >= 17.0.0
~> 17.1, >= 17.1.1
 Project Readme

Cucumber Open - Supported by Smartbear

Cucumber

OpenCollective OpenCollective pull requests issues Test cucumber Code Climate Coverage Status

Cucumber is a tool for running automated tests written in plain language. Because they're written in plain language, they can be read by anyone on your team. Because they can be read by anyone, you can use them to help improve communication, collaboration and trust on your team.

Cucumber Gherkin Example

This is the Ruby implementation of Cucumber. Cucumber is also available for JavaScript, Java, and a lot of other languages. You can find a list of implementations here: https://cucumber.io/docs/installation/.

See CONTRIBUTING.md for info on contributing to Cucumber (issues, PRs, etc.).

Everyone interacting in this codebase and issue tracker is expected to follow the Cucumber code of conduct.

Installation

Cucumber for Ruby is a Ruby gem. Install it as you would install any gem: add cucumber to your Gemfile:

gem 'cucumber'

then install it:

$ bundle

or install the gem directly:

$ gem install cucumber

Later in this document, bundler is considered being used so all commands are using bundle exec. If this is not the case for you, execute cucumber directly, without bundle exec.

Supported platforms

  • Ruby 3.0
  • Ruby 2.7
  • Ruby 2.6
  • Ruby 2.5
  • Ruby 2.4
  • Ruby 2.3
  • JRuby 9.2 (with some limitations)

JRuby 9.3 is not supported yet due to a known issue. More info can be found in the PR#1571.

Ruby on Rails

Using Ruby on Rails? You can use cucumber-rails to bring Cucumber into your Rails project.

Usage

Initialization

If you need to, initialize your features directory with

$ bundle exec cucumber --init

This will create the following directories and files if they do not exist already:

features
├── step_definitions
└── support
    └── env.rb

Create your specification

Create a file named rule.feature in the features directory with:

# features/rule.feature

Feature: Rule Sample

  Rule: This is a rule

    Example: A passing example
      Given this will pass
      When I do an action
      Then some results should be there

    Example: A failing example
      Given this will fail
      When I do an action
      Then some results should be there

Automate your specification

And a file named steps.rb in features/step_definitions with:

# features/step_definitions/steps.rb

Given("this will pass") do
  @this_will_pass = true
end

Given("this will fail") do
  @this_will_pass = false
end

When("I do an action") do
end

Then("some results should be there") do
  expect(@this_will_pass)
end

Run Cucumber

$ bundle exec cucumber

To execute a single feature file:

$ bundle exec cucumber features/rule.feature

To execute a single example, indicates the line of the name of the example:

$ bundle exec cucumber features/rule.feature:7

To summarize the results on the standard output, and writte a HTML report on disk:

$ bundle exec cucumber --format summary --format html --out report.html

For more command line options

$ bundle exec cucumber --help

You can also find documentation on the command line possibilities in features/docs/cli.

Documentation and support

Copyright

Copyright (c) Cucumber Ltd. and Contributors. See LICENSE for details.