SoftwareTestPilot
8 Q&A · 3 Years Experience

BDD Cucumber Interview Questions for 3 Years Experience (2026)

BDD Cucumber & Gherkin DSL interview questions for BDD Automation Engineers with 3 years of experience.

  • 3 min read
  • Difficulty: Medium
  • 3 yr · BDD Automation
  • Updated October 2026
  • SoftwareTestPilot
SoftwareTestPilot
QA Editorial Team
Published:
0 / 8 reviewed
0%

1. Writing Good Gherkin

Medium Very Common 1 minQ1 / 8

Q1.What makes a Gherkin scenario good or bad?

Detailed explanation

Short answer: a good scenario describes behaviour in business language (declarative). A bad one lists UI clicks (imperative), so it breaks whenever the screen changes and nobody outside QA reads it.

# Imperative - avoid
Given I open "/login"
When I type "qa@example.com" into "#email"
And I click "#submit"

# Declarative - prefer
Given a registered customer
When they sign in with valid details
Then they see their order history

One scenario should check one behaviour; if you need many Then lines about unrelated things, split it.

RelatedQ3
Easy Very Common 1 minQ2 / 8

Q2.When do you use Scenario Outline?

Detailed explanation

Short answer: when the same behaviour must be checked with different data. Each Examples row runs as its own scenario.

Scenario Outline: Coupon rules
  Given a cart worth <total> rupees
  When the customer applies coupon "<code>"
  Then the discount is <discount> rupees

  Examples:
    | total | code    | discount |
    | 1000  | SAVE10  | 100      |
    | 300   | SAVE10  | 0        |

Avoid huge Examples tables; data-heavy checks are often better as unit or API tests.

Medium Very Common 1 minQ3 / 8

Q3.Background vs hooks: which should you use for setup?

Detailed explanation

Short answer: use Background for setup that a business reader needs to see ("Given a logged-in customer"). Use hooks (@Before) for technical setup readers do not care about (starting a browser, clearing a database).

Keep Background short; if it grows, the feature file probably covers too many behaviours.

Confidence check

If you can confidently answer the Writing Good Gherkin questions above, you're well prepared for this section of your interview. Move on, or rehearse the trickier ones aloud with our AI mock interviewer.

2. Step Definitions, Hooks and Running Suites

Easy Common 1 minQ4 / 8

Q4.How do step definitions match steps, and what are Cucumber expressions?

Detailed explanation

Short answer: each step text is matched to a method by a Cucumber expression (or a regular expression). Parameter types like {int} and {string} are converted for you.

@Given("a cart worth {int} rupees")
public void aCartWorth(int total) { cart = carts.createWithTotal(total); }

@When("the customer applies coupon {string}")
public void applyCoupon(String code) { result = cart.apply(code); }

Common failures: undefined step (no match - Cucumber prints a snippet to paste) and ambiguous step (two methods match - make one expression more specific).

Medium Common 1 minQ5 / 8

Q5.How do you share state between step definition classes?

Detailed explanation

Short answer: use dependency injection (for example cucumber-picocontainer). Cucumber creates one instance of a shared context class per scenario and passes it to every step class that asks for it. Do not use static fields - they leak between scenarios and break parallel runs.

public class ScenarioContext { public Cart cart; public Response lastResponse; }

public class CartSteps {
    private final ScenarioContext ctx;
    public CartSteps(ScenarioContext ctx) { this.ctx = ctx; }  // injected
}
Medium Occasional 1 minQ6 / 8

Q6.How do you attach a screenshot when a scenario fails?

Detailed explanation

Short answer: an @After hook receives the Scenario; check isFailed() and attach the image so it appears in the report.

@After
public void afterScenario(Scenario scenario) {
    if (scenario.isFailed()) {
        byte[] png = ((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES);
        scenario.attach(png, "image/png", scenario.getName());
    }
    driver.quit();
}

Tagged hooks such as @Before("@db") run only for scenarios with that tag.

Easy Occasional 1 minQ7 / 8

Q7.How do you run only some scenarios using tags?

Detailed explanation

Short answer: tag scenarios or features and pass a tag expression.

mvn test -Dcucumber.filter.tags="@smoke and not @wip"

Tag expressions support and, or, not and brackets. Keep a small agreed tag list (@smoke, @regression, @wip) so tags stay meaningful.

Medium Occasional 1 minQ8 / 8

Q8.How do you run Cucumber scenarios in parallel with JUnit 5?

Detailed explanation

Short answer: with the cucumber-junit-platform-engine, enable parallel execution in junit-platform.properties:

cucumber.execution.parallel.enabled=true
cucumber.execution.parallel.config.strategy=fixed
cucumber.execution.parallel.config.fixed.parallelism=4

Before turning it on, make sure drivers and scenario context are per-scenario (injected, not static) and that scenarios do not share test data.

RelatedQ6
Confidence check

If you can confidently answer the Step Definitions, Hooks and Running Suites questions above, you're well prepared for this section of your interview. Move on, or rehearse the trickier ones aloud with our AI mock interviewer.

Quick revision

  1. Q1: What makes a Gherkin scenario good or bad — Short answer: a good scenario describes behaviour in business language (declarative).
  2. Q2: When do you use Scenario Outline — Short answer: when the same behaviour must be checked with different data.
  3. Q3: Background vs hooks: which should you use for setup — Short answer: use Background for setup that a business reader needs to see ("Given a logged-in customer").
  4. Q4: How do step definitions match steps, and what are Cucumber expressions — Short answer: each step text is matched to a method by a Cucumber expression (or a regular expression).
  5. Q5: How do you share state between step definition classes — Short answer: use dependency injection (for example cucumber-picocontainer ).

Frequently asked questions

1.Is BDD the same as using Cucumber?
No. BDD is a way of agreeing on behaviour with examples before building it. Cucumber is one tool that turns those examples into automated checks. Interviewers often ask this to see whether you know the difference.
2.What do 3-year BDD interviews focus on?
Writing readable Gherkin, matching steps cleanly, sharing state safely, hooks and reporting, tags and parallel runs.

BDD Cucumber jobs hiring now

Live, indexable BDD Cucumber openings — updated daily in Jobs Radar.

Browse all QA jobs on Jobs Radar

Loading current openings…

Home