If you’re preparing for a Senior QA Automation Engineer interview, chances are you’ll be asked several questions about Cucumber, Behavior-Driven Development (BDD), Scenario Outline, Data Tables, and framework design. While most candidates know the basics, interviewers often look for practical knowledge gained from real automation projects. In this guide, you’ll find 25+ commonly asked Cucumber interview questions and answers, complete with Java code examples and best practices used in enterprise automation frameworks.
What is Cucumber?
Cucumber is a Behavior-Driven Development (BDD) testing framework that enables collaboration between business analysts, developers, and QA engineers through executable specifications written in Gherkin.
Unlike traditional automation scripts, Cucumber scenarios are written in plain English, making them understandable to both technical and non-technical stakeholders.
Example:
Feature: LoginScenario: Successful LoginGiven user is on Login pageWhen user enters valid credentialsThen user should be logged in
1. What is Gherkin?
Gherkin is the language used to write Cucumber feature files.
Common keywords include:
- Feature
- Scenario
- Given
- When
- Then
- And
- But
- Background
- Scenario Outline
- Examples
These keywords help describe application behavior in a readable format.
2. Explain Given, When and Then
A Cucumber scenario generally follows the Arrange–Act–Assert pattern.
- Given – Defines the initial state or precondition.
- When – Performs the action.
- Then – Verifies the expected outcome.
Example:
Scenario: Product SearchGiven Amazon homepage is openWhen user searches for "Laptop"Then search results should be displayed
3. What is the difference between Scenario and Scenario Outline?
A Scenario executes once with fixed data.
Scenario: LoginGiven username "admin"When password "admin123"Then login should succeed
A Scenario Outline executes the same scenario multiple times using different datasets from the Examples table.
Scenario Outline: Login ValidationGiven username "<username>"When password "<password>"Then result should be "<status>"Examples:| username | password | status || admin | admin123 | Success || admin | wrong123 | Failure |
Interview Tip: Mention that every row in the Examples table creates a separate test execution.
4. Explain Scenario Outline with Java Example
Feature:
Scenario Outline: AdditionGiven first number is <num1>And second number is <num2>When numbers are addedThen result should be <result>Examples:| num1 | num2 | result || 10 | 20 | 30 || 5 | 15 | 20 |
Step Definition:
private int num1;private int num2;private int result;@Given("first number is {int}")public void firstNumber(int n1){ num1 = n1;}@Given("second number is {int}")public void secondNumber(int n2){ num2 = n2;}@When("numbers are added")public void addNumbers(){ result = num1 + num2;}@Then("result should be {int}")public void verifyResult(int expected){ Assert.assertEquals(expected, result);}
Best Practice: Use Scenario Outline whenever the same workflow must be validated with multiple input combinations.
5. What is a Data Table?
A Data Table allows multiple rows and columns of data to be passed into a single step.
Scenario: Create UsersGiven the following users exist| username | email || John | john@test.com || Mike | mike@test.com || David | david@test.com |
6. How do you read a Data Table?
@Given("the following users exist")public void usersExist(DataTable table){ List<Map<String,String>> users = table.asMaps(String.class,String.class); for(Map<String,String> user : users){ System.out.println(user.get("username")); System.out.println(user.get("email")); }}
This approach is commonly used when creating multiple users, validating bulk API requests, or submitting multiple form entries.
7. Scenario Outline vs Data Table
One of the most frequently asked Cucumber interview questions is the difference between these two concepts.
| Scenario Outline | Data Table |
|---|---|
| Executes multiple times | Executes once |
| Uses Examples table | Uses structured table data |
| Best for data-driven testing | Best for bulk input |
| Each row creates a new execution | Entire table is processed together |
Use Scenario Outline when:
- Login validation
- Search functionality
- Form validation
- Cross-browser inputs
Use Data Tables when:
- Bulk user creation
- API payloads
- Employee records
- Shopping cart items
8. Can Scenario Outline and Data Table be used together?
Yes.
A Scenario Outline can dynamically populate values inside a Data Table, allowing each scenario execution to work with different structured input.
This technique is useful when testing large and reusable datasets.
9. What is Background?
Background contains common steps executed before every scenario within the same feature file.
Example:
Background:Given user is logged in
It helps eliminate duplicate setup steps.
10. What are Tags?
Tags allow selective execution of scenarios.
Example:
@SmokeScenario: Login@RegressionScenario: Logout
Runner:
tags="@Smoke"
Complex example:
tags="(@Smoke or @Regression) and not @Ignore"
11. What are Hooks?
Hooks execute before or after scenarios.
@Beforepublic void setup(){}@Afterpublic void teardown(){}
Hooks are typically used for:
- Browser launch
- Browser closure
- Driver initialization
- Screenshot capture
- Logging
- Database cleanup
- API cleanup
12. Background vs Hooks
Many interviewers ask this question.
| Background | Hooks |
|---|---|
| Written in Feature file | Written in Java |
| Business readable | Technical implementation |
| Visible to stakeholders | Hidden implementation |
| Business setup | Automation setup |
13. Explain the Cucumber Test Runner
The Test Runner controls how Cucumber executes the automation suite.
A typical runner includes:
- @RunWith(Cucumber.class)
- @CucumberOptions
- features
- glue
- tags
- plugin
- monochrome
- dryRun
- publish
Example:
@RunWith(Cucumber.class)@CucumberOptions(features="src/test/resources/features",glue={"stepdefinitions","hooks"},tags="@Smoke",monochrome=true,dryRun=false,plugin={"pretty","html:target/report.html","json:target/report.json","junit:target/report.xml","rerun:target/failed.txt"})public class TestRunner{}
14. Explain the Most Important Runner Components
features
Location of feature files.
glue
Location of Step Definitions and Hooks.
tags
Execute only selected scenarios.
plugin
Generates HTML, JSON, XML, and rerun reports.
monochrome
Produces cleaner console output.
dryRun
Validates that every feature file step has a matching Step Definition without executing tests.
publish
Publishes Cucumber reports online.
15. Frequently Asked Interview Questions
What happens if glue is incorrect?
Cucumber cannot locate Step Definitions, and every scenario will fail with Undefined Steps.
What is the purpose of dryRun?
It verifies that all feature file steps are implemented but skips test execution.
What is the rerun plugin?
It records failed scenarios so that only failed tests can be executed in the next run.
Which runner options are used most often?
- features
- glue
- tags
- plugin
- monochrome
- dryRun
- publish
Final Interview Tip
Experienced QA Automation Engineers are expected to go beyond explaining syntax. Interviewers often expect you to discuss where and why you would use Scenario Outline, Data Tables, Hooks, Tags, and Runner configurations in a maintainable automation framework.
When answering, use practical examples from Selenium, Playwright, or API automation projects, explain the trade-offs, and emphasize maintainability, readability, and reusability. That approach demonstrates real-world experience rather than textbook knowledge.
Conclusion
Mastering these Cucumber interview questions and answers will help you confidently explain BDD concepts, framework design, and automation best practices during technical interviews. Focus on understanding the reasoning behind each feature instead of memorizing definitions, and you’ll be well prepared for Senior QA Automation Engineer roles.
Related Links
Cucumber JUnit5 Test Runner Setup
Why most Cucumber Projects are not actually doing BDD
Discover more from Rotebit
Subscribe to get the latest posts sent to your email.


Pingback: Cucumber Test Runner Plugins with JUnit 5 - Rotebit