What is Gherkin?

  • Share on Facebook
  • Share on Twitter
  • Share on LinkedIn
  • Share on HackerNews

Gherkin is a domain-specific language (DSL) which is used for describing the behavior of a system. It reads like plain English, which makes it easy to understand for non-technical people.

Because of these characteristics, it makes for an excellent language to be used when writing tests. Tests written with Gherkin are easy to read by non-technical people and QA, as these tests can be read like stories.

Keyword-Based Syntax

Gherkin relies on specific keywords to structure its scenarios. The most commonly used keywords include:

  • Feature
  • Scenario
  • Given
  • When
  • Then

Most of the time when writing a test, you would start from a precondition, a trigger would change something and you would finally check its outcome. This can be perfectly worded in Gherkin syntax.

Given a glass of water, When I drop the glass, Then the glass will break and the floor will be wet.

Gherkin and Cucumber

Cucumber is an automation framework that interprets Gherkin scenarios. It will translate the corresponding steps in code and target the SUT (System Under Test).

In the case of Selenium, Cucumber will convert the Gherkin syntax to Selenium WebDriver commands, instrumenting a browser.

TestingBot provides various Cucumber examples, showcasing how to run Cucumber tests on remote browsers.

  • Share on Facebook
  • Share on Twitter
  • Share on LinkedIn
  • Share on HackerNews
TestingBot Logo

Sign up for a Free Trial

Start testing your apps with TestingBot.

No credit card required.

Other Questions