Top Cucumber Interview Questions for SDET

Beknazar
3 min readDec 20, 2023

Hi there! I put together the top Cucumber interview questions for SDET or Test Automation roles.

Please consider taking my Udemy course Interview Preparation for SDET(Java) if you prefer video sessions with more detailed explanations.

What is Cucumber?

Cucumber is a tool for running automated tests, written in plain language. Cucumber was built to support Behavior-Driven-Development (BDD).

Source: https://github.com/cucumber

What are the benefits of using Cucumber?

  • The code becomes reusable once the framework matures.
  • Easier understanding of the test logic from readable scenarios.

What is Gherkin Language?

It is a language we use to write Cucumber scenarios.

What are the main components of Cucumber?

  • Feature files. That’s where we write our tests as Cucumber Scenarios with steps.
  • Step Definitions. The implementation of steps with actual automation script.
  • Runner. It is the execution point for Cucumber. It connects Feature files with their Step Definitions.

What does the runner class do? Can you describe what is inside?

It is the execution point for Cucumber. It connects Feature files with their Step Definitions.

What are the Features, Scenarios, and Steps in the Gherkin language?

  • Feature keyword is to provide a high-level description of a software feature and to group related scenarios.
  • Scenario (Example) keyword illustrates a business rule for your test. It consists of a list of steps.
  • Steps: Given, When, Then, And, and But. They represent the actual steps of your test case. Cucumber executes each step one by one in the sequence.

What is the Step Definition component?

A Step Definition is a method with an expression that links it to one or more Cucumber Steps. When a Step is executed, it will look for a matching step definition to execute.

What is the Scenario Outline in Cucumber?

The Scenario Outline keyword can be used to run the same scenario multiple times, with different combinations of values.

What is the Background in Cucumber?

We can create the Background steps that run before each scenario but after Hook. We can use Background steps to avoid duplication. It is good practice to keep it short.

What is Hook in Cucumber?

  • Hooks are blocks of code that can run at various points of the Cucumber execution cycle. They are typically used for setup and teardown of the environment before and after each scenario.
  • Scenario hooks: @Before, @After
  • Step hooks: @BeforeStep, @AfterStep

How does parameterized value work in Cucumber?

You can pass values to the step definition method from your scenario step

  • Numbers are parameterized by default.
  • Strings between double quotes are parameterized.
  • You can use Data Tables to pass multiple values.

How would you run only smoke test scenarios or only regression test scenarios in Cucumber?

We can use Cucumber tags

mvn test -Dcucumber.options="--tags@smoke"

Thank you for your attention. Please consider taking my online courses:

--

--