Jump to content

Cucumber (software): Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Reverted good faith edits by Sabrozz (talk): No need
Lcdrovers (talk | contribs)
remove implication that specflow is "the" (definite article) port to .NET, or that cucumber is not open-source, which could be considered advertising
Tags: Mobile edit Mobile web edit
Line 18: Line 18:
'''Cucumber''' is a [[software]] tool that supports [[behavior-driven development]] (BDD).<ref name="TheCucumberBook">{{cite web |url=http://pragprog.com/book/hwcuc/the-cucumber-book |title=The Pragmatic Bookshelf &#124; The Cucumber Book |publisher=Pragprog.com |access-date=2012-01-24 |archive-url=https://web.archive.org/web/20120121022646/http://pragprog.com/book/hwcuc/the-cucumber-book |archive-date=2012-01-21 |url-status=dead }}</ref><ref name="TheCucumberForJavaBook">{{cite book|url=https://pragprog.com/book/srjcuc/the-cucumber-for-java-book |title=The Pragmatic Bookshelf &#124; The Cucumber For Java Book |publisher=Pragprog.com |author1=Rose, Seb|author2=Wynne, Matt|author3=Hellesøy, Aslak|date=15 February 2015 |access-date=2019-04-28}}</ref><ref>{{cite web |title=What is Cucumber? |website=cucumber |url=https://cucumber.io/docs/guides/overview/ |access-date=2019-06-08}}</ref><ref>{{cite web |title=The world's most misunderstood collaboration tool |author=Aslak Hellesøy |website=cucumber |url=https://cucumber.io/blog/the-worlds-most-misunderstood-collaboration-tool/}}</ref> Central to the Cucumber BDD approach is its ordinary language parser called [[Gherkin (software)|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.<ref>{{Cite book|title=Engineering Software as a Service |last=Fox|first=Armando|last2=Patterson|first2=David|publisher=Strawberry Canyon|year=2016|isbn=978-0-9848812-4-6|pages=218–255}}</ref><ref name="TheCucumberBook"/><ref name="TheCucumberForJavaBook"/> It is often used for testing other software.<ref>{{Cite web|url=https://www.ibm.com/developerworks/library/a-automating-ria/|title=Automated testing with Selenium and Cucumber|date=2013-08-06|website=www.ibm.com|language=en|access-date=2017-02-09}}</ref> It runs automated [[acceptance testing|acceptance tests]] written in a [[behavior-driven development]] (BDD) style.<ref>{{Cite book|title=Objects, Models, Components, Patterns |last=Soeken |first=Mathias |last2=Wille|first2=Robert|last3=Drechsler|first3=Rolf|date=2012-05-29|publisher=Springer Berlin Heidelberg|isbn=9783642305603|editor-last=Furia|editor-first=Carlo A.|series=Lecture Notes in Computer Science |pages=269–287 |language=en|doi=10.1007/978-3-642-30561-0_19|editor-last2=Nanz|editor-first2=Sebastian}}</ref>
'''Cucumber''' is a [[software]] tool that supports [[behavior-driven development]] (BDD).<ref name="TheCucumberBook">{{cite web |url=http://pragprog.com/book/hwcuc/the-cucumber-book |title=The Pragmatic Bookshelf &#124; The Cucumber Book |publisher=Pragprog.com |access-date=2012-01-24 |archive-url=https://web.archive.org/web/20120121022646/http://pragprog.com/book/hwcuc/the-cucumber-book |archive-date=2012-01-21 |url-status=dead }}</ref><ref name="TheCucumberForJavaBook">{{cite book|url=https://pragprog.com/book/srjcuc/the-cucumber-for-java-book |title=The Pragmatic Bookshelf &#124; The Cucumber For Java Book |publisher=Pragprog.com |author1=Rose, Seb|author2=Wynne, Matt|author3=Hellesøy, Aslak|date=15 February 2015 |access-date=2019-04-28}}</ref><ref>{{cite web |title=What is Cucumber? |website=cucumber |url=https://cucumber.io/docs/guides/overview/ |access-date=2019-06-08}}</ref><ref>{{cite web |title=The world's most misunderstood collaboration tool |author=Aslak Hellesøy |website=cucumber |url=https://cucumber.io/blog/the-worlds-most-misunderstood-collaboration-tool/}}</ref> Central to the Cucumber BDD approach is its ordinary language parser called [[Gherkin (software)|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.<ref>{{Cite book|title=Engineering Software as a Service |last=Fox|first=Armando|last2=Patterson|first2=David|publisher=Strawberry Canyon|year=2016|isbn=978-0-9848812-4-6|pages=218–255}}</ref><ref name="TheCucumberBook"/><ref name="TheCucumberForJavaBook"/> It is often used for testing other software.<ref>{{Cite web|url=https://www.ibm.com/developerworks/library/a-automating-ria/|title=Automated testing with Selenium and Cucumber|date=2013-08-06|website=www.ibm.com|language=en|access-date=2017-02-09}}</ref> It runs automated [[acceptance testing|acceptance tests]] written in a [[behavior-driven development]] (BDD) style.<ref>{{Cite book|title=Objects, Models, Components, Patterns |last=Soeken |first=Mathias |last2=Wille|first2=Robert|last3=Drechsler|first3=Rolf|date=2012-05-29|publisher=Springer Berlin Heidelberg|isbn=9783642305603|editor-last=Furia|editor-first=Carlo A.|series=Lecture Notes in Computer Science |pages=269–287 |language=en|doi=10.1007/978-3-642-30561-0_19|editor-last2=Nanz|editor-first2=Sebastian}}</ref>


Cucumber was originally written in the [[Ruby (programming language)|Ruby programming language]].<ref name="TheCucumberBook" /><ref name="TheRSpecBook">{{cite web |url=http://pragprog.com/book/achbd/the-rspec-book |title=The Pragmatic Bookshelf &#124; The RSpec Book |publisher=Pragprog.com |date=2010-12-02 |access-date=2012-01-24 |archive-url=https://web.archive.org/web/20120121003856/http://pragprog.com/book/achbd/the-rspec-book |archive-date=2012-01-21 |url-status=dead }}</ref><ref name="TheCucumberForJavaBook" /> 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 (programming language)|Java]]<ref>{{cite web|url=https://github.com/cucumber/cucumber-jvm|title=Cucumber-jvm|publisher=cucumber|access-date=2018-03-08}}</ref><ref name="TheCucumberForJavaBook" /> and [[JavaScript]].<ref>{{cite web|url=https://github.com/cucumber/cucumber-js|title=Cucumber-js |publisher=cucumber |access-date=2018-03-08}}</ref><ref>{{cite web|url=https://open.nytimes.com/no-code-no-problem-writing-tests-in-plain-english-537827eaaa6e |title=No Code? No Problem — Writing Tests in Plain English |publisher=Times Open |date=2019-02-01 |author1=Naidele Manjunath |author2=Olivier de Meulder |access-date=2019-04-29}}</ref> The open source port of Cucumber in [[.NET Framework|.NET]] is called SpecFlow.<ref>{{cite web |url=https://specflow.org/ |title=Binding Business Requirements to .NET Code |work=SpecFlow |access-date=2019-04-29}}</ref><ref>{{cite web |url=https://github.com/techtalk/SpecFlow |title=SpecFlow |work=GitHub |access-date=2019-04-29}}</ref><ref>{{cite book |title=Behavior-Driven Development with Cucumber |author1=Richard Lawrence |author2=Paul Rayner |publisher=Addison Wesley |date=2018}}</ref>
Cucumber was originally written in the [[Ruby (programming language)|Ruby programming language]].<ref name="TheCucumberBook" /><ref name="TheRSpecBook">{{cite web |url=http://pragprog.com/book/achbd/the-rspec-book |title=The Pragmatic Bookshelf &#124; The RSpec Book |publisher=Pragprog.com |date=2010-12-02 |access-date=2012-01-24 |archive-url=https://web.archive.org/web/20120121003856/http://pragprog.com/book/achbd/the-rspec-book |archive-date=2012-01-21 |url-status=dead }}</ref><ref name="TheCucumberForJavaBook" /> 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 (programming language)|Java]]<ref>{{cite web|url=https://github.com/cucumber/cucumber-jvm|title=Cucumber-jvm|publisher=cucumber|access-date=2018-03-08}}</ref><ref name="TheCucumberForJavaBook" /> and [[JavaScript]].<ref>{{cite web|url=https://github.com/cucumber/cucumber-js|title=Cucumber-js |publisher=cucumber |access-date=2018-03-08}}</ref><ref>{{cite web|url=https://open.nytimes.com/no-code-no-problem-writing-tests-in-plain-english-537827eaaa6e |title=No Code? No Problem — Writing Tests in Plain English |publisher=Times Open |date=2019-02-01 |author1=Naidele Manjunath |author2=Olivier de Meulder |access-date=2019-04-29}}</ref> There is a port of Cucumber to [[.NET Framework|.NET]] called SpecFlow.<ref>{{cite web |url=https://specflow.org/ |title=Binding Business Requirements to .NET Code |work=SpecFlow |access-date=2019-04-29}}</ref><ref>{{cite web |url=https://github.com/techtalk/SpecFlow |title=SpecFlow |work=GitHub |access-date=2019-04-29}}</ref><ref>{{cite book |title=Behavior-Driven Development with Cucumber |author1=Richard Lawrence |author2=Paul Rayner |publisher=Addison Wesley |date=2018}}</ref>


==Gherkin language==
==Gherkin language==

Revision as of 02:28, 23 June 2023

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] Edit this on Wikidata / 7 May 2023; 11 December 2023; 16 January 2024
Repository
Written inRuby
Operating systemCross-platform
TypeBehavior driven development framework / Test tool
LicenseMIT License
Websitecucumber.io

Cucumber is a software tool that supports behavior-driven development (BDD).[7][8][9][10] 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.[11][7][8] It is often used for testing other software.[12] It runs automated acceptance tests written in a behavior-driven development (BDD) style.[13]

Cucumber was originally written in the Ruby programming language.[7][14][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[15][8] and JavaScript.[16][17] There is a port of Cucumber to .NET called SpecFlow.[18][19][20]

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][21][22] 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.[22] Gherkin currently supports keywords in dozens of languages.[22][23][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.[22] # is used as the line-comment character, and can be placed anywhere in a file.[22] Instructions are any non-empty and non-comment line. They consist of a recognized Gherkin keyword followed by a string.[24]

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.[24]

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.[25]

$ 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.[25] Arguments can be provided as a logical OR or AND operation of tags. Apart from tags, scenarios can be filtered on scenario names.[25]

$ cucumber --name logout

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.[25]

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. ^ a b c d e "The Pragmatic Bookshelf | The Cucumber Book". Pragprog.com. Archived from the original on 2012-01-21. Retrieved 2012-01-24.
  8. ^ a b c d e f 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. ^ Fox, Armando; Patterson, David (2016). Engineering Software as a Service. Strawberry Canyon. pp. 218–255. ISBN 978-0-9848812-4-6.
  12. ^ "Automated testing with Selenium and Cucumber". www.ibm.com. 2013-08-06. Retrieved 2017-02-09.
  13. ^ 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.
  14. ^ "The Pragmatic Bookshelf | The RSpec Book". Pragprog.com. 2010-12-02. Archived from the original on 2012-01-21. Retrieved 2012-01-24.
  15. ^ "Cucumber-jvm". cucumber. Retrieved 2018-03-08.
  16. ^ "Cucumber-js". cucumber. Retrieved 2018-03-08.
  17. ^ Naidele Manjunath; Olivier de Meulder (2019-02-01). "No Code? No Problem — Writing Tests in Plain English". Times Open. Retrieved 2019-04-29.
  18. ^ "Binding Business Requirements to .NET Code". SpecFlow. Retrieved 2019-04-29.
  19. ^ "SpecFlow". GitHub. Retrieved 2019-04-29.
  20. ^ Richard Lawrence; Paul Rayner (2018). Behavior-Driven Development with Cucumber. Addison Wesley.
  21. ^ "cucumber/gherkin". GitHub. Retrieved 2017-02-09.
  22. ^ a b c d e "Gherkin Syntax". cucumber. Retrieved 2019-07-09.
  23. ^ "Gherkin Supported Languages". Gherkin. cucumber/cucumber: Cucumber monorepo - building blocks for Cucumber in various languages. Retrieved 2021-03-21 – via GitHub.
  24. ^ a b "Reference". cucumber. Archived from the original on 2015-10-25. Retrieved 2016-01-17.
  25. ^ a b c d Wynne, Matt; Hellesoy, Aslak. "The Cucumber Book". SafariBooksOnline. Retrieved 22 January 2016.