Cucumber (software)

Last updated
Cucumber
Developer(s) Aslak Hellesøy, [1] Joseph Wilk, [2] Matt Wynne, [3] Gregory Hnatiuk, [4] Mike Sassak [5]
Stable release
9.1.2 [6]   OOjs UI icon edit-ltr-progressive.svg / 7 May 2023; 11 December 2023; 16 January 2024
Repository
Written in Ruby
Operating system Cross-platform
Type Behavior driven development framework / Test tool
License MIT License
Website cucumber.io

Cucumber is a software tool that supports behavior-driven development (BDD). [7] [8] [9] [10] [11] [12] Central to the Cucumber BDD approach is its ordinary language parser called Gherkin. It allows expected software behaviors to be specified in a logical language that customers can understand. As such, Cucumber allows the execution of feature documentation written in business-facing text. [13] [7] [8] It is often used for testing other software. [14] It runs automated acceptance tests written in a behavior-driven development (BDD) style. [15]

Contents

Cucumber was originally written in the Ruby programming language. [7] [16] [8] and was originally used exclusively for Ruby testing as a complement to the RSpec BDD framework. Cucumber now supports a variety of different programming languages through various implementations, including Java [17] [8] and JavaScript. [18] [19] There is a port of Cucumber to .NET called SpecFlow, [20] [21] [22] now superseded by Reqnroll. [23]

Gherkin language

Gherkin is the language that Cucumber uses to define test cases. It is designed to be non-technical and human readable, and collectively describes use cases relating to a software system. [7] [8] [24] [25] The purpose behind Gherkin's syntax is to promote behavior-driven development practices across an entire development team, including business analysts and managers. It seeks to enforce firm, unambiguous requirements starting in the initial phases of requirements definition by business management and in other stages of the development lifecycle.

In addition to providing a script for automated testing, Gherkin's natural language syntax is designed to provide simple documentation of the code under test. [25] Gherkin currently supports keywords in dozens of languages. [25] [26] [7] [8]

Syntax

Syntax is centered around a line-oriented design, similar to that of Python. The structure of a file is defined using whitespace and other control characters. [25] Lines starting with # are considered comments, and can be placed anywhere in a file. [25] Instructions are any non-empty and non-comment line. They consist of a recognized Gherkin keyword followed by a string. [27]

All Gherkin files have the .feature file extension. They contain a single Feature definition for the system under test and are an executable test script. [27]

Here is an example of the syntax: [28]

Feature: Guess the word  # The first example has two stepsScenario: Maker starts a game    When the Maker starts a gameThen the Maker waits for a Breaker to join  # The second example has three stepsScenario: Breaker joins a game    Given the Maker has started a game with the word "silky"When the Breaker joins the Maker's gameThen the Breaker must guess a word with 5 characters

Command line

Cucumber comes with a built-in command line interface that covers a comprehensive list of instructions. Like most command line tools, cucumber provides the --help option that provides a summary of arguments the command accepts. [29]

$ cucumber--help         -r, --require LIBRARY|DIR        Require files before executing the features.        --i18n LANG                      List keywords for in a particular language.                                         Run with "--i18n help" to see all languages.        -f, --format FORMAT              How to format features (Default: pretty).        -o, --out [FILE|DIR]             Write output to a file/directory instead of        ...

Cucumber command line can be used to quickly run defined tests. It also supports running a subset of scenarios by filtering tags.

$ cucumber--tags@tag-name 

The above command helps in executing only those scenarios that have the specified @tag-name. [29] Arguments can be provided as a logical OR or AND operation of tags. Apart from tags, scenarios can be filtered on scenario names. [29]

$ cucumber--namelogout

The above command will run only those scenarios that contain the word 'logout'.

It is also useful to be able to know what went wrong when a test fails. Cucumber makes it easy to catch bugs in the code with the --backtrace option. [29]

Related Research Articles

Io is a pure object-oriented programming language inspired by Smalltalk, Self, Lua, Lisp, Act1, and NewtonScript. Io has a prototype-based object model similar to those in Self and NewtonScript, eliminating the distinction between instance and class. Like Smalltalk, everything is an object and it uses dynamic typing. Like Lisp, programs are just data trees. Io uses actors for concurrency.

In computer programming, glob patterns specify sets of filenames with wildcard characters. For example, the Unix Bash shell command mv *.txttextfiles/ moves all files with names ending in .txt from the current directory to the directory textfiles. Here, * is a wildcard and *.txt is a glob pattern. The wildcard * stands for "any string of any length including empty, but excluding the path separator characters ".

<span class="mw-page-title-main">Apache Groovy</span> Programming language

Apache Groovy is a Java-syntax-compatible object-oriented programming language for the Java platform. It is both a static and dynamic language with features similar to those of Python, Ruby, and Smalltalk. It can be used as both a programming language and a scripting language for the Java Platform, is compiled to Java virtual machine (JVM) bytecode, and interoperates seamlessly with other Java code and libraries. Groovy uses a curly-bracket syntax similar to Java's. Groovy supports closures, multiline strings, and expressions embedded in strings. Much of Groovy's power lies in its AST transformations, triggered through annotations.

A domain-specific language (DSL) is a computer language specialized to a particular application domain. This is in contrast to a general-purpose language (GPL), which is broadly applicable across domains. There are a wide variety of DSLs, ranging from widely used languages for common domains, such as HTML for web pages, down to languages used by only one or a few pieces of software, such as MUSH soft code. DSLs can be further subdivided by the kind of language, and include domain-specific markup languages, domain-specific modeling languages, and domain-specific programming languages. Special-purpose computer languages have always existed in the computer age, but the term "domain-specific language" has become more popular due to the rise of domain-specific modeling. Simpler DSLs, particularly ones used by a single application, are sometimes informally called mini-languages.

cURL is a computer software project providing a library (libcurl) and command-line tool (curl) for transferring data using various network protocols. The name stands for "Client for URL".

In computer-based language recognition, ANTLR, or ANother Tool for Language Recognition, is a parser generator that uses a LL(*) algorithm for parsing. ANTLR is the successor to the Purdue Compiler Construction Tool Set (PCCTS), first developed in 1989, and is under active development. Its maintainer is Professor Terence Parr of the University of San Francisco.

BeanShell is a small, free, embeddable Java source interpreter with object scripting language features, written in Java. It runs in the Java Runtime Environment (JRE), dynamically executes standard Java syntax and extends it with common scripting conveniences such as loose types, commands, and method closures, like those in Perl and JavaScript.

<span class="mw-page-title-main">Markdown</span> Plain text markup language

Markdown is a lightweight markup language for creating formatted text using a plain-text editor. John Gruber created Markdown in 2004 as an easy-to-read markup language. Markdown is widely used for blogging and instant messaging, and also used elsewhere in online forums, collaborative software, documentation pages, and readme files.

Behavior-driven development (BDD) involves naming software tests using domain language to describe the behavior of the code.

HTML Tidy is a console application for correcting invalid HyperText Markup Language (HTML), detecting potential web accessibility errors, and for improving the layout and indent style of the resulting markup. It is also a cross-platform library for computer applications that provides HTML Tidy's features.

<span class="mw-page-title-main">TextMate</span> GUI text editor for macOS

TextMate is a free and open-source general-purpose GUI text editor for macOS created by Allan Odgaard. TextMate features declarative customizations, tabs for open documents, recordable macros, folding sections, snippets, shell integration, and an extensible bundle system.

RSpec is a computer domain-specific language (DSL) testing tool written in the programming language Ruby to test Ruby code. It is a behavior-driven development (BDD) framework which is extensively used in production applications. The basic idea behind this concept is that of test-driven development (TDD) where the tests are written first and the development is based on writing just enough code that will fulfill those tests followed by refactoring. It contains its own mocking framework that is fully integrated into the framework based upon JMock. The simplicity in the RSpec syntax makes it one of the popular testing tools for Ruby applications. The RSpec tool can be used by installing the rspec gem which consists of three other gems, namely rspec-core, rspec-expectation and rspec-mock.

Urbi is an open-source cross-platform software computing platform written in C++ used to develop applications for robotics and complex systems. Urbi is based on the UObject distributed C++ component architecture. It also includes the urbiscript orchestration language which is a parallel and event-driven script language. UObject components can be plugged into urbiscript and appear as native objects that can be scripted to specify their interactions and data exchanges. UObjects can be linked to the urbiscript interpreter, or executed as autonomous processes in "remote" mode.

<span class="mw-page-title-main">Clojure</span> Dialect of the Lisp programming language on the Java platform

Clojure is a dynamic and functional dialect of the programming language Lisp on the Java platform.

<span class="mw-page-title-main">Jasmine (software)</span> Open-source testing framework for JavaScript

Jasmine is an open-source testing framework for JavaScript. It aims to run on any JavaScript-enabled platform, to not intrude on the application nor the IDE, and to have easy-to-read syntax. It is heavily influenced by other unit testing frameworks, such as ScrewUnit, JSSpec, JSpec, and RSpec.

Concordion is a specification by example framework originally developed by David Peterson, and now maintained by a team of contributors, led by Nigel Charman.

Ace is a standalone code editor written in JavaScript. The goal is to create a web-based code editor that matches and extends the features, usability, and performance of existing native editors such as TextMate, Vim, or Eclipse. It can be easily embedded in any web page and JavaScript application. Ace is developed as the primary editor for Cloud9 IDE and as the successor of the Mozilla Skywriter project.

Acceptance test–driven development (ATDD) is a development methodology based on communication between the business customers, the developers, and the testers. ATDD encompasses many of the same practices as specification by example (SBE), behavior-driven development (BDD), example-driven development (EDD), and support-driven development also called story test–driven development (SDD). All these processes aid developers and testers in understanding the customer's needs prior to implementation and allow customers to be able to converse in their own domain language.

<span class="mw-page-title-main">Behat (software)</span>

Behat is a test framework for behavior-driven development written in the PHP programming language. Behat was created by Konstantin Kudryashov and its development is hosted on GitHub.

References

  1. "Aslak Hellesøy". Aslakhellesoy.com. Retrieved 2012-01-24.
  2. "Joseph Wilk | on AI, The Web, Usability, Testing & Software process". Blog.josephwilk.net. Retrieved 2012-01-24.
  3. "Tea-Driven Development". Blog.mattwynne.net. Retrieved 2012-01-24.
  4. "ghnatiuk's Profile". GitHub. Retrieved 2012-01-24.
  5. "msassak's Profile". GitHub. Retrieved 2012-01-24.
  6. "Release 9.1.2". 7 May 2023. Retrieved 30 May 2023.
  7. 1 2 3 4 5 "The Pragmatic Bookshelf | The Cucumber Book". Pragprog.com. Archived from the original on 2012-01-21. Retrieved 2012-01-24.
  8. 1 2 3 4 5 6 Rose, Seb; Wynne, Matt; Hellesøy, Aslak (15 February 2015). The Pragmatic Bookshelf | The Cucumber For Java Book. Pragprog.com. Retrieved 2019-04-28.
  9. "What is Cucumber?". cucumber. Retrieved 2019-06-08.
  10. Aslak Hellesøy. "The world's most misunderstood collaboration tool". cucumber.
  11. Nagy, Gáspár; Rose, Seb (2017-03-07). The BDD Books - Discovery. Leanpub. ISBN   978-1983591259.{{cite book}}: CS1 maint: date and year (link)
  12. Rose, Seb; Nagy, Gáspár (2021-04-27). The BDD Books – Formulation. Leanpub. ISBN   979-8723395015.{{cite book}}: CS1 maint: date and year (link)
  13. Fox, Armando; Patterson, David (2016). Engineering Software as a Service. Strawberry Canyon. pp. 218–255. ISBN   978-0-9848812-4-6.
  14. "Automated testing with Selenium and Cucumber". www.ibm.com. 2013-08-06. Retrieved 2017-02-09.
  15. Soeken, Mathias; Wille, Robert; Drechsler, Rolf (2012-05-29). Furia, Carlo A.; Nanz, Sebastian (eds.). Objects, Models, Components, Patterns. Lecture Notes in Computer Science. Springer Berlin Heidelberg. pp. 269–287. doi:10.1007/978-3-642-30561-0_19. ISBN   9783642305603.
  16. "The Pragmatic Bookshelf | The RSpec Book". Pragprog.com. 2010-12-02. Archived from the original on 2012-01-21. Retrieved 2012-01-24.
  17. "Cucumber-jvm". cucumber. Retrieved 2018-03-08.
  18. "Cucumber-js". cucumber. Retrieved 2018-03-08.
  19. Naidele Manjunath; Olivier de Meulder (2019-02-01). "No Code? No Problem — Writing Tests in Plain English". Times Open. Retrieved 2019-04-29.
  20. "Binding Business Requirements to .NET Code". SpecFlow. Retrieved 2019-04-29.
  21. "SpecFlow". GitHub. Retrieved 2019-04-29.
  22. Richard Lawrence; Paul Rayner (2018). Behavior-Driven Development with Cucumber. Addison Wesley.
  23. Nagy, Gáspár (8 February 2024). "From SpecFlow to Reqnroll: Why and How". reqnroll.net. Reqnroll. Retrieved 18 April 2024.
  24. "cucumber/gherkin". GitHub. Retrieved 2017-02-09.
  25. 1 2 3 4 5 "Gherkin Syntax". cucumber. Retrieved 2019-07-09.
  26. "Gherkin Supported Languages". Gherkin. cucumber/cucumber: Cucumber monorepo - building blocks for Cucumber in various languages. Retrieved 2021-03-21 via GitHub.
  27. 1 2 "Reference". cucumber. Archived from the original on 2015-10-25. Retrieved 2016-01-17.
  28. "Gherkin Reference". cucumber. Archived from the original on 2024-01-13. Retrieved 2024-02-11.
  29. 1 2 3 4 Wynne, Matt; Hellesoy, Aslak. "The Cucumber Book". SafariBooksOnline. Retrieved 22 January 2016.