Summary
Gherkin is the domain-specific language used to express BDD test scenarios. Its Given/When/Then structure makes test cases readable by non-technical stakeholders while remaining executable by test frameworks.
What is Gherkin?
Gherkin provides a small vocabulary—Feature, Scenario, Given, When, Then, And, But—that describes software behaviour without referring to implementation details. A Feature file groups related scenarios for a single piece of functionality. Each Scenario describes a specific case through context (Given), action (When), and expected outcome (Then).
Frameworks like Cucumber, Behave, and SpecFlow parse Gherkin files and match each step to a step definition—a code snippet that drives the application. This keeps the natural-language specification and the executable test tightly coupled.
Gherkin supports data-driven testing via Scenario Outlines with Examples tables, allowing one template to run against multiple input sets without duplicating scenario text.
Why is Gherkin relevant?
- Shared language: A single format that business analysts, QA, and developers all read and contribute to
- Executable specification: Scenarios are both documentation and automated tests, preventing drift
- Broad framework support: Gherkin is supported by Cucumber (JVM, Ruby, JavaScript), Behave (Python), SpecFlow (.NET), and more