</>

Technology

Cucumber

Difficulty

Beginner

Interview Question

What language is used by Cucumber?

Answer

Gherkin — The Language of Cucumber

Cucumber uses Gherkin as its language. Gherkin is a simple, plain-English representation of application behavior that can be understood by both technical and non-technical stakeholders.

Key Characteristics

  • Human-readable, plain text format
  • Structured around business behavior (not implementation)
  • Understood by Business Analysts, Developers, and QA
  • Each .feature file is written in Gherkin

Core Gherkin Keywords

KeywordPurpose
FeatureHigh-level description of the feature under test
ScenarioA specific test case
Scenario OutlineParameterized scenario for multiple data sets
GivenPrecondition / initial state
WhenAction performed by the user
ThenExpected outcome / assertion
AndContinues a Given/When/Then step
ButNegative continuation
BackgroundCommon steps that run before each scenario
ExamplesData table for Scenario Outline

Example Feature File

Gherkin
Feature: User Login

  Scenario: Successful login with valid credentials
    Given the user is on the login page
    When the user enters username "admin" and password "Admin@123"
    And the user clicks the Login button
    Then the user should be redirected to the dashboard
    And the welcome message "Welcome, Admin" should be displayed

Why Gherkin?

  • Collaboration: Non-technical stakeholders write/review tests
  • Living documentation: Feature files serve as up-to-date docs
  • BDD bridge: Links business requirements to automated tests

Follow AutomateQA

Related Topics