Cucumber Interview Questions

If you don’t know what is Cucumber and BDD – check out here.

What is Cucumber?

The cucumber is a tool based on Behavior Driven Development (BDD) framework which is used to write acceptance tests for the web application. It allows automation of functional validation in easily readable and understandable format to Business Analysts, Developers, Testers, etc.The language that Cucumber understands is called Gherkin. It is written in a Ruby programming language.

What are the advantages of Cucumber?

Advantages of Cucumber:
1- You can involve business stakeholders who can not code.
2- End user experience is the priority.
3- High code reuse.

Explain What Is BDD (Behavior Driven Development)?

BDD or Behaviour-driven development is a process of developing software based on TDD (Test Driven Development) which focuses on the behavioral specification of software units.

What is the profile in cucumber?

We can create Cucumber profiles to run specific features and step definitions.We can use the following command to execute a cucumber profile.

cucumber features -p Ex: cucumber features -p regression

What is the cucumber.yml file in cucumber?

In the cucumber.yml file we will create profiles.

What Is Support, Env.rb And Hooks.rb?

Support is a folder where we can setup cucumber related support.
Env.rb file will be used to load the required libraries for cucumber scenario execution
hooks.rb we will add hooks like before, after, beforeStep and afterStep hooks.

Explain feature in Cucumber?

A Feature can be defined as a standalone unit or functionality of a project. Let’s take a very common example of a social networking site.

How does the feature of this product/project look like?

Few basic features can be determined as –
– Create and remove the user from the social networking site.
– User login functionality for the social networking site.
– Sharing photos or videos on the social networking site.
– Sending a friend request.
– Logout.

Explain the parts/keywords of feature file?

A simple feature file consists of the following keywords/parts –
Feature- Name of the feature under test.
Description (optional)- Describe about feature under test.
Scenario- What is the test scenario.
Given- Prerequisite before the test steps get executed.
When- Specific condition which should match in order to execute the next step.
Then- What should happen if the condition mentioned in WHEN is satisfied.

Explain What Is Scenario Outline In Feature File?

Scenario Outline: Same scenario can be executed for multiple sets of data using scenario outline. The data is provided by a tabular structure separated by (I I).

What Is Step Definition In Cucumber?

A step definition is the actual code implementation of the feature mentioned in the feature file.

What is cucumber dry run?

Cucumber dry run is used to compile cucumber feature files and step Definitions. If there are any compilation errors it will show when we use dry run

Cucumber features –dry-run

What are the two files which you need to run a Cucumber test scenario?

If you want to execute a Cucumber test, then make sure it has the following two files.
1- A feature file.
2- A step definition file.

What Are Before, After, BeforeStep And AfterStep Hooks?

Before: execute before the feature file execution
After: executes after the feature file execution
BeforeStep: executes before the each step execution
AfterStep: executes after the each step execution

Explain What Is Test Harness?

A test harness for cucumber and rspec allows for separating responsibility between setting up the context and interacting with the browser and cleaning up the step definition files.

What Are Cucumber Tags? Why We Use The Tags?

Cucumber tags used to filter the scenarios. We can tag the scenarios and we can execute the scenarios based on tags, We can add tags to scenarios with @ We can use the following command to execute a cucumber tagged scenarios.

cucumber features -t @
Ex: cucumber features -t @test

Explain What Is Regular Expressions?

A regular expression is a pattern describing a certain amount of text. The most basic regular expression consists of a single literal character.

What are the prereqs for building a Selenium Cucumber automation framework?

You might like to consider the following facts while creating a productive and scalable test framework:
– Identify the type of application you are going to test. Is it a Web app, support mobile devices or runs on a desktop.
– Would it require backend testing? e.g. Databases or SDK.
– Do you need to test the app for internationalization?
– It must have a report which can help you trace a failure with minimum efforts.
– It must support auto-generation of parametrization tests.
– Have a config file to define any setup related settings or the global properties.
– Apply abstraction at every level to separate the functionality.

How to integrate Cucumber with Selenium Webdriver?

It’s the most obvious Selenium Webdriver Cucumber interview question which you must know. And it’s better if you give a step by step reply to the interviewer. It’ll leave a positive impression on him as you’ll show the depth of your knowledge.
1- Cucumber is a testing framework to run acceptance test cases. It creates scripts using the BDD approach.
2- It makes use of a feature file which describes the test cases in plain text format.
3- Here you write tests in simple English. And later use the Selenium Webdriver to run the test scripts.
4- To start Cucumber with Selenium, first of all, you require creating a Maven project in Eclipse.
5- In the Maven’s POM file, you add the Cucumber dependency which brings the support of annotations
6- Similarly, you can introduce the Selenium dependency into the above project. Alternatively, you can download the latest version of Selenium standalone jar from their website. And then, add to your project as an external jar file.

Explain JUnit Runner?

To run the specific feature file cucumber uses standard JUnit Runner and specify tags in @Cucumber. Options. Multiple tags can be given by using comma separate. Here you can specify the path of the report and type of report you want to generate.
Example of Junit Runner:


import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;


Public class JUnitRunner {


Are there any readymade Selenium-Cucumber frameworks available?

Yes, there are a few we are listing down below. Though, we recommend building one of your own as it gives you more freedom.
1- Selenium-Cucumber framework for testing the web and Android apps.
2- Another one is an acceptance testing framework using Cucumber and Selenium WebDriver.

What is ORM in Rails?

ORM tends for Object-Relationship-Model, it means that your Classes are mapped to table in the database, and Objects are directly mapped to the rows in the table.

List out some of the main differences between Jbehave and Cucumber?

However, the Cucumber and Jbehave share the same perspective, but there are few key differences.
1- Jbehave is Java-based and Cucumber is Ruby-based.
2- Jbehave is story-driven whereas the Cucumber is feature-driven.

What software do you need to run a Cucumber Web Test?

-Ruby and its Development Kit
-IDE like ActiveState
-Watir ( To simulate browser)
-Ansicon and rspec (if required)

What are the steps to generate a report in Cucumber?

We run the following command to produce HTML reports.

cucumber .feature --format html --out report.html --format pretty

What is the right way to execute a specific scenario from the feature file?

We can select the target scenario from a feature file by providing its line number.

cucumber features/test.feature:10 --format html > testfeature.html

  • Facebook
  • Twitter
  • Google+
  • Linkedin
  • Pinterest

Leave a Comment

Your email address will not be published. Required fields are marked *

It is main inner container footer text