Let’s Take a Look to Cucumber

Numanhan Duran
2 min readJan 26, 2022

What is Cucumber?

Cucumber is a Behavior-Driven Development powered testing tool.

The situations to be tested are in English by default using a grammatical structure called Gherkin, but they can also be written in many other languages, including Turkish, using existing translations, by making simple sentences. In this way, it allows even people who do not have any technical knowledge to create software tests. Since it is very easy to setup, write and use tests, it makes test writing fun and easy by saving it from being a tiring and boring situation.

The Cucumber tool has been developed with the Ruby language and supports writing tests in many languages, especially Ruby, Python, Java, JavaScript, C++ , Lua, Kotlin, .NET and PHP.

What is Gherkin?

Gherkin is the generic name for the grammar structure used when writing test cases with Cucumber. Since the sentences formed in this structure, which is very simple and easy to understand, are very close to the sentences in the daily spoken language, it creates the feeling of talking to the software while writing the test cases.

The Gherkin language makes use of certain keywords.

The keywords used to name a test and scenarios are as follows:

  • Feature: Name of Feature to Test
  • Scenario: Scenario Name to be Applied
  • Scenario Outline: It is used to create a draft scenario when it is necessary to run the same scenario for more than one situation.

The following keywords are also used to define the action steps to be applied in the defined scenario. Each of these processes is called a “step”.

  • Given: Defines the initial state of the system. It allows the system to enter a defined state.
  • When: It is used to describe an event or action. An action to be taken is written after this keyword.
  • Then: It is used to describe an expected result or situation. The expression in which we compare the expected situation with the actual situation is written after this keyword.
  • And , But: These keywords are used when the above-mentioned Given ,When and Then expressions are desired to be written more than once.

By briefly talking about Cucumber and Gherkin, we saw how we can create a test scenario in BDD format. In the next articles, we can go deeper by explaining with examples. I hope it was a useful writing.

--

--