Skip to content

Latest commit

 

History

History
187 lines (126 loc) · 5.59 KB

README.md

File metadata and controls

187 lines (126 loc) · 5.59 KB

Cucumber Open - Supported by Smartbear

Cucumber

OpenCollective OpenCollective pull requests issues CircleCI 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

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)

Ruby on Rails

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

Usage

<<<<<<< HEAD

Test your Gherkin specifications

Once installed, you can run Cucumber from the command line like this:

$ bundle exec cucumber

Cucumber will look for a features directory and search it for Gherkin specifications (files with a .feature extension) to execute.

=======

main

Initialization

If you need to, initialize your features directory with

<<<<<<< HEAD $ bundle exec cucumber --init

$ cucumber --init

main

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

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

<<<<<<< HEAD

Create your specification

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

# features/rule.feature

=======
### Creating your features and step definitions

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

```gherkin
# features/rule.feature

>>>>>>> main
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

<<<<<<< HEAD

Automate your specification

=======

main 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

<<<<<<< HEAD

Run Cucumber

=======

Running Cucumber

main

$ cucumber

To execute a single feature file:

$ cucumber features/rule.feature

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

$ cucumber features/rule.feature:7

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

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

For more command line options

$ 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.