Core automation track

BDD with Cucumber

Readable specs on top of a proper Page Object framework.

What this track covers

Gherkin syntaxFeature & ScenarioScenario OutlineStep DefinitionsHooksTagsDataTablesRunner configurationParallel executionReporting

Feature to step definition

Gherkin describes behaviour; step definitions delegate to page objects — never to raw WebDriver.

Why it is required: Interviewers check whether BDD is used as a reporting gimmick or a real layer.

Example: A checkout scenario driven by a Scenario Outline.

gherkin
1@smoke @checkout
2Scenario Outline: Customer completes checkout
3 Given I am logged in as "<user>"
4 When I add "<product>" to the cart
5 And I complete checkout
6 Then the order total should be "<total>"
7
8 Examples:
9 | user | product | total |
10 | standard_user | Sauce Labs Backpack | $32.39 |
11 | premium_user | Sauce Labs Bike Light| $10.79 |

Expected result

Two scenarios generated from one specification, tagged for selective execution.

Common mistakes

  • WebDriver calls inside step definitions
  • Sharing state via static fields instead of DI
  • Scenario titles describing UI clicks instead of behaviour

How do you share data between steps in the same scenario?

Related interview questions

Open bank
  • How do you share state between Cucumber step definitions?

    Use dependency injection (PicoContainer) with a scenario-scoped context object — never static fields.

Quick reference available

Open the matching cheat sheet for last-minute revision.