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 Core is the inner hexagon for the Ruby flavour of Cucumber.
It contains the core domain logic to execute Cucumber features. It has no user interface, just a Ruby API. If you're interested in how Cucumber works, or in building other tools that work with Gherkin documents, you've come to the right place.
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.
cucumber-core
is a Ruby gem. Install it as you would install any gem: add
cucumber-core
to your Gemfile:
gem 'cucumber-core'
then install it:
$ bundle
or install the gem directly:
$ gem install cucumber-core
- Ruby 3.2
- Ruby 3.1
- Ruby 3.0
- Ruby 2.7
- Ruby 2.6
- Ruby 2.5
- Ruby 2.4
- JRuby 9.2 (with some limitations)
The following example aims to illustrate how to use cucumber-core
gem and to
make sure it is working well within your environment. For more details
explanation on what it actually does and how to work with it, see
docs/ARCHITECTURE.md.
# cucumber_core_example.rb
require 'cucumber/core'
require 'cucumber/core/filter'
class ActivateSteps < Cucumber::Core::Filter.new
def test_case(test_case)
test_steps = test_case.test_steps.map do |step|
step.with_action { print "processing: " }
end
test_case.with_steps(test_steps).describe_to(receiver)
end
end
feature = Cucumber::Core::Gherkin::Document.new(__FILE__, <<-GHERKIN)
Feature:
Scenario:
Given some requirements
When we do something
Then it should pass
GHERKIN
class MyRunner
include Cucumber::Core
end
MyRunner.new.execute([feature], [ActivateSteps.new]) do |events|
events.on(:test_step_finished) do |event|
test_step, result = event.test_step, event.result
print "#{test_step.text} #{result}\n"
end
end
If you run this Ruby script:
ruby cucumber_core_example.rb
You should see the following output:
processing: some requirements ✓
processing: we do something ✓
processing: it should pass ✓
- Getting started with Cucumber, writing features, step definitions, and more: https://cucumber.io/docs
- Slack: register for an account then head over to #intro
cucumber-core
overview: docs/ARCHITECTURE.md- How to work with local repositories for
cucumber-gherkin
,cucumber-messages
orcucumber-ruby
: CONTRIBUTING.md#working-with-local-cucumber-dependencies
Copyright (c) Cucumber Ltd. and Contributors. See LICENSE for details.