BDD and Cucumber interview questions

// 21 QUESTIONS Β· UPDATED MAY 2026

BDD and Cucumber interview questions covering Gherkin syntax, feature files, step definitions, scenario outlines, data tables, hooks, tags, parallel execution, and the trade-offs of BDD in practice. Includes examples in both Java and JavaScript.

Level

Showing 21 of 21 questions

  1. What is BDD, and how does it differ from TDD?Junior

    BDD (Behaviour-Driven Development) extends TDD by writing tests in plain language that all stakeholders can read. TDD focuses on unit-lev…

  2. Explain the Given / When / Then structure in Gherkin and what each keyword means.Junior

    Given sets up the precondition (context), When describes the action the user or system takes, Then asserts the expected outcome. And / Bu…

  3. What is a feature file and what sections does it contain?Junior

    A feature file is a plain-text file (extension .feature) written in Gherkin that describes one feature of the application. It contains a…

  4. What are step definitions, and how does Cucumber match a Gherkin step to code?Junior

    Step definitions are the glue code that maps each Gherkin step to an executable function. Cucumber matches steps using regular expression…

  5. What is the difference between Scenario and Scenario Outline in Cucumber?Junior

    Scenario is a single, concrete test case. Scenario Outline is a template that runs once per row in an Examples table, with column values…

  6. What is the Background keyword in Gherkin and what are its limitations?Junior

    Background contains Given steps that run before every Scenario in the same feature file β€” like a shared precondition. It should only incl…

  7. What are data tables in Gherkin and how are they different from Scenario Outline Examples?Junior

    A data table is an inline table passed as an argument to a single step β€” it's part of that step's data, not a template for repeating the…

  8. How do tags work in Cucumber and how do you run only specific tagged scenarios?Junior

    Tags are @-prefixed labels placed above Feature or Scenario keywords. They control which scenarios run via tag expressions in the CLI or…

  9. What are hooks in Cucumber, what types exist, and what should (and shouldn't) go in them?Mid

    Hooks are functions that run at specific points in the test lifecycle β€” @Before, @After (per scenario), @BeforeStep, @AfterStep (per step…

  10. How do you share state between step definitions in Cucumber without using static variables?Mid

    In Java, use dependency injection (PicoContainer, Spring, Guice) to inject a shared context object into each step definition class. In Ja…

  11. How do you structure Cucumber step definitions with the Page Object Model?Mid

    Step definitions are thin glue β€” they call Page Object methods. Page Objects contain locators and actions. Inject Page Objects into step…

  12. When does BDD help a team and when does it get in the way?Mid

    BDD helps when stakeholders are genuinely involved in writing and reviewing scenarios, and when feature behaviour is complex enough to be…

  13. What are the most common BDD anti-patterns and how do you fix them?Senior

    The most damaging anti-patterns are: UI-coupled steps, scenario obsession (too many scenarios), feature file siloing, developer-written s…

  14. Who should write and own feature files in a BDD team, and how do you prevent them from becoming stale?Senior

    Feature files are best co-authored by the 3 amigos (BA/PO, developer, QA) in a structured conversation before work starts. QA typically o…

  15. How do you run Cucumber scenarios in parallel, and what are the key pitfalls?Senior

    Cucumber supports parallel execution via the parallel plugin (Maven Surefire/Failsafe), JUnit 5 parallel execution config, or native JS w…

  16. How do you transform data tables into typed domain objects in Cucumber?Senior

    Use DataTable.asMaps() for a list of string maps, or register a DataTableType (Java) / defineDataTableType (JS) to automatically convert…

  17. What is living documentation in the context of BDD, and how do you achieve it in practice?Senior

    Living documentation means the feature files are the single source of truth for feature behaviour β€” they're always up-to-date because the…

  18. When would you choose Karate over Cucumber for API testing?Senior

    Karate for API-only testing β€” no step definition glue code, built-in HTTP/JSON/XML support, schema assertion, and mocking. Cucumber when…

  19. How do you configure Cucumber in a Java project, and what are the key @CucumberOptions settings?Mid

    @CucumberOptions on the test runner class sets the feature file path, step definition package, plugin list (reporters), tags, and monochr…

  20. What is Example Mapping and how does it improve the BDD process?Senior

    Example Mapping is a structured 3-amigos conversation technique (30-60 min) that uses colour-coded index cards to explore a user story: y…

  21. How do you write step definitions that are reusable without becoming too generic or ambiguous?Mid

    Write steps at the right level of abstraction β€” specific enough to be meaningful in context, general enough to be reused across scenarios…