Software:Cucumber

From HandWiki
Short description: Software tool
Cucumber
Developer(s)Aslak Hellesøy,[1] Joseph Wilk,[2] Matt Wynne,[3] Gregory Hnatiuk,[4] Mike Sassak[5]
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).[6][7][8][9] 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.[10][6][7] It is often used for testing other software.[11] It runs automated acceptance tests written in a behavior-driven development (BDD) style.[12]

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

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.[6][7][20][21] 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.[21] Gherkin currently supports keywords in dozens of languages.[21][22][6][7]

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

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

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

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

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

References

  1. "Aslak Hellesøy". Aslakhellesoy.com. http://aslakhellesoy.com/. 
  2. "Joseph Wilk | on AI, The Web, Usability, Testing & Software process". Blog.josephwilk.net. http://blog.josephwilk.net/. 
  3. "Tea-Driven Development". Blog.mattwynne.net. http://blog.mattwynne.net/. 
  4. "ghnatiuk's Profile". GitHub. https://github.com/ghnatiuk. 
  5. "msassak's Profile". GitHub. https://github.com/msassak. 
  6. 6.0 6.1 6.2 6.3 6.4 "The Pragmatic Bookshelf | The Cucumber Book". Pragprog.com. http://pragprog.com/book/hwcuc/the-cucumber-book. 
  7. 7.0 7.1 7.2 7.3 7.4 7.5 Rose, Seb; Wynne, Matt; Hellesøy, Aslak (15 February 2015). The Pragmatic Bookshelf | The Cucumber For Java Book. Pragprog.com. https://pragprog.com/book/srjcuc/the-cucumber-for-java-book. Retrieved 2019-04-28. 
  8. "What is Cucumber?". https://cucumber.io/docs/guides/overview/. 
  9. Aslak Hellesøy. "The world's most misunderstood collaboration tool". https://cucumber.io/blog/the-worlds-most-misunderstood-collaboration-tool/. 
  10. Fox, Armando; Patterson, David (2016). Engineering Software as a Service. Strawberry Canyon. pp. 218–255. ISBN 978-0-9848812-4-6. 
  11. "Automated testing with Selenium and Cucumber" (in en). 2013-08-06. https://www.ibm.com/developerworks/library/a-automating-ria/. 
  12. Soeken, Mathias; Wille, Robert; Drechsler, Rolf (2012-05-29). Furia, Carlo A.. ed (in en). 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. 
  13. "The Pragmatic Bookshelf | The RSpec Book". Pragprog.com. 2010-12-02. http://pragprog.com/book/achbd/the-rspec-book. 
  14. "Cucumber-jvm". cucumber. https://github.com/cucumber/cucumber-jvm. 
  15. "Cucumber-js". cucumber. https://github.com/cucumber/cucumber-js. 
  16. "No Code? No Problem — Writing Tests in Plain English". Times Open. 2019-02-01. https://open.nytimes.com/no-code-no-problem-writing-tests-in-plain-english-537827eaaa6e. 
  17. "Binding Business Requirements to .NET Code". SpecFlow. https://specflow.org/. 
  18. "SpecFlow". GitHub. https://github.com/techtalk/SpecFlow. 
  19. Richard Lawrence; Paul Rayner (2018). Behavior-Driven Development with Cucumber. Addison Wesley. 
  20. "cucumber/gherkin" (in en). https://github.com/cucumber/cucumber/tree/master/gherkin. 
  21. 21.0 21.1 21.2 21.3 21.4 "Gherkin Syntax". https://cucumber.io/docs/gherkin/. 
  22. "Gherkin Supported Languages". https://github.com/cucumber/cucumber/blob/master/gherkin/gherkin-languages.json. 
  23. 23.0 23.1 "Reference". https://cucumber.io/docs/reference. 
  24. 24.0 24.1 24.2 24.3 Wynne, Matt; Hellesoy, Aslak. "The Cucumber Book". https://www.safaribooksonline.com/library/view/the-cucumber-book/9781941222911/f_0090.html. 

External links