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.
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.