Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Cucumber for Ruby. It's amazing!

License

NotificationsYou must be signed in to change notification settings

cucumber/cucumber-ruby

Repository files navigation

Cucumber

Stand With UkraineOpenCollectiveOpenCollectiveTest cucumberCode ClimateCoverage Status

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

Cucumber Gherkin Example

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

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

Everyone interacting in this codebase and issue tracker is expected to follow theCucumbercode of conduct.

Installation

Cucumber for Ruby is a Ruby gem. Install it as you would install any gem: addcucumber 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 usingbundle exec. If this is not the case for you, executecucumber directly, withoutbundle exec.

Supported platforms

  • Ruby 3.2
  • Ruby 3.1
  • Ruby 3.0
  • Ruby 2.7
  • TruffleRuby 22.0.0+
  • JRuby 9.4+ (withsome limitations)

Ruby on Rails

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

Usage

Initialization

If you need to, initialize yourfeatures 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 namedrule.feature in thefeatures directory with:

# features/rule.featureFeature: Rule Sample  Rule: This is a rule    Example: A passing exampleGiventhis will passWhenI do an actionThensome results should be there    Example: A failing exampleGiventhis will failWhenI do an actionThensome results should be there

Automate your specification

And a file namedsteps.rb infeatures/step_definitions with:

# features/step_definitions/steps.rbGiven('this will pass')do@this_will_pass=trueendGiven('this will fail')do@this_will_pass=falseendWhen('I do an action')do:no_opendThen("some results should be there")doexpect(@this_will_pass).tobetrueend

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:5

To summarize the results on the standard output, and generate 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 infeatures/docs/cli.

Documentation and support

Copyright

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


[8]ページ先頭

©2009-2025 Movatter.jp