Other meanings of Cucumber (software)
Software Testing
Cucumber is an open-source testing tool that supports behavior-driven development (BDD), allowing tests to be written in plain language using the Gherkin syntax. It bridges the gap between technical and non-technical stakeholders by enabling executable specifications.
Cucumber is a testing framework that implements behavior-driven development (BDD), a methodology that encourages collaboration between developers, QA, and non-technical stakeholders. It uses Gherkin, a domain-specific language that describes software behavior in a human-readable format. Gherkin files contain features, scenarios, and steps, which are then mapped to executable code via step definitions. This allows tests to serve as living documentation, ensuring that the specification is always up-to-date with the actual behavior.1
The core idea is to write tests in a Given-When-Then structure, which describes the initial context, the action, and the expected outcome. Cucumber parses these plain-text descriptions and executes the corresponding code, making it a powerful tool for automated acceptance testing. It supports multiple programming languages, including Ruby, Java, JavaScript, and Python, through various implementations.
Cucumber was created by Aslak Hellesøy in 2008 as a Ruby-based tool, inspired by the earlier BDD framework JBehave. It quickly gained popularity in the Ruby community and later expanded to other languages. The project is now maintained by SmartBear, which acquired Cucumber Ltd in 2019.
Over the years, Cucumber has evolved to include a command-line interface, a JUnit integration for Java, and a JavaScript implementation called Cucumber.js. The Gherkin language has also been standardized, with a formal grammar and a reference implementation. In 2021, Cucumber introduced the Cucumber Expressions feature, which simplifies step definition patterns compared to regular expressions.
Gherkin is a line-oriented language that uses indentation to define structure. A typical Gherkin file starts with a Feature keyword, followed by a description. Scenarios are defined with the Scenario keyword, and steps are written using Given, When, Then, And, and But. Gherkin also supports Scenario Outline for data-driven testing, where placeholders are replaced with values from an Examples table.2
Gherkin is designed to be language-agnostic, with translations available in over 70 languages. This makes it accessible to international teams. The syntax is strict, and any deviation from the grammar can cause parsing errors, ensuring that the specification remains unambiguous.
Cucumber integrates with popular testing frameworks and CI/CD pipelines. In Java, it works with JUnit and TestNG; in JavaScript, it pairs with Mocha or Jest; in Ruby, it uses RSpec or Minitest. It also provides plugins for build tools like Maven, Gradle, and npm. Cucumber supports parallel execution, which speeds up test suites, and it can generate reports in various formats, including HTML, JSON, and JUnit XML.3
The Cucumber ecosystem includes a commercial product called Cucumber Studio (formerly Cucumber Pro), which offers a collaborative platform for writing and managing Gherkin scenarios. Additionally, there are community-driven extensions for code editors, such as Visual Studio Code and IntelliJ IDEA, that provide syntax highlighting and autocomplete for Gherkin files.
One lesser-known aspect is that Cucumber can be used for non-functional testing, such as performance or security testing, by writing scenarios that trigger load or security checks. Another is the existence of 'Cucumber for Jira', a plugin that links Gherkin scenarios to Jira issues, enabling traceability.
Historically, Cucumber was initially called 'Cuke' and was influenced by the 'Story Runner' from RSpec. The name 'Cucumber' was chosen because it is a vegetable that is green, reflecting the project's Ruby origins (Ruby is a gemstone, and gems are often associated with vegetables in the Ruby community). Additionally, Cucumber supports 'hooks' (Before, After, Around) that allow setup and teardown logic, and it can be extended with custom formatters and plugins.
Cucumber is a registered trademark of SmartBear Software.
Help improve the encyclopedia. Reports go straight to the site manager.