Skip to main content
Automation
DEFINITION

What is Gherkin?

Gherkin is a plain-language, structured syntax for writing Behavior-Driven Development scenarios using keywords like Feature, Scenario, Given, When, Then, And, and But.

Free to start · 7-day trial on paid plans

IN DEPTH

In depth.

Gherkin lets teams describe software behavior in a way both humans and automation tools can read. A .feature file starts with a Feature describing the capability, then contains one or more Scenarios. Each scenario uses Given to set context, When to trigger an action, and Then to assert the outcome, with And/But chaining additional steps.

Gherkin supports Scenario Outline with an Examples table for data-driven cases, Background for shared setup, and tags (@smoke, @regression) for selective execution. Tools such as Cucumber, SpecFlow, Behave, and Karate parse these steps and bind them to step-definition code (Karate notably needs no glue code).

Good Gherkin is declarative and reads like documentation: "When the user submits the form" rather than imperative UI mechanics like "When the user clicks #submit". Overly technical, brittle steps are the most common smell, they couple business documentation to implementation detail and defeat the purpose of a shared language.

WHY IT MATTERS

Why interviewers ask about this.

QA and SDET interviews use Gherkin to check whether you can write maintainable, declarative scenarios rather than imperative click-by-click scripts that break on every UI change.

EXAMPLE

Example scenario.

A team writes Gherkin steps full of CSS selectors and explicit waits. Every UI tweak breaks dozens of scenarios. They refactor to declarative business steps ("Given a logged-in premium user") and push the mechanics into step definitions, so product owners can read the features and the suite stops breaking on cosmetic changes.

TIP

Interview tip.

Show that you know the difference between declarative and imperative steps, and mention Scenario Outline and Background. Bonus points for noting that Karate uses Gherkin without separate step definitions.

FAQ

Frequently asked questions.

Is Gherkin a programming language?

No. Gherkin is a structured natural-language syntax. The automation logic lives in step definitions written in a real language (Java, Python, JS, C#), except in tools like Karate that interpret the steps directly.

What makes a good Gherkin scenario?

It is declarative, focuses on business behavior rather than UI mechanics, stays short (a handful of steps), and avoids selectors or technical detail so non-developers can read it.

FREE TOOLS  /  no signup

Free QA career tools, no account needed

Instant and private, everything runs in your browser. Try them before you sign up.

EXEC.NOW

Ready to Ace Your QA Interview?

Practice explaining gherkin and other key concepts with our AI interviewer.

Join 1,200+ QA engineers already practicing with AssertHired.

Start your free QA interview
FREE.TO.START  ·  7.DAY.TRIAL ON PAID PLANS
Written by Aston Cook, Senior QA EngineerLast updated May 2026