Cucumber
is a tool that can execute plain-text
functional descriptions. And also it’s BDD(Behaviour Driven Development)
automated tests
. It is written by Ruby
, and now it supports more than 40 languages, such as Java
, C#
and Scala
etc.
Install
Firstly, we need to install Ruby
and RubyGems
, to check whether the installation of Ruby and RubyGems is successful. You can inputx the commands to terminal, just like as below:
1 | ~ ruby --version |
And then we can run the command below to install Cucumber
:
1 | ~ gem install cucumber |
After this, put below command to see how to use it.
1 | ~ cucumber --help |
Gherkin
Gherkin
is a language that can be understand by Cucumber
. It’s a Business Readable
, Domain Specific Language
. Very easy to understand what the functional want to do.
The Gherkin
has two purpose, documention and automated test. The structure is Treetop grammer than is part of Cucumber codebase and use indentation to format it.
The Gherkin
has two conventions:
- Single
Gherkin
source file contains a description of single feature. - The source file is feature extention file(
*.feature
).
Like YAML(Yet Another Markup Language)
, Gherkin is a line-oriented language that uses indentation to define structure. Most lines start with keyword. And you can start with a hash sign(#) to comment the text.
A Gherkin source file usually looks like this
1 | 1: Feature: Some terse yet descriptive text of what is desired |
Above the codes, It’s very similar with Given-When-Then
the Feature
, Scenario
, Given
, And
, When
, Then
all are keywords of Gherkin
.