Register Login

Cucumber Interview Questions and Answers

Updated Feb 22, 2019

What is Cucumber framework?

The Cucumber framework is used for testing software. It is very useful for executing acceptance test scenarios during the development process, a behaviour is commonly known as BDD (Behavior Driven Development).

What are the advantages of Cucumber framework?

The advantages of Cucumber framework are:

  • Cucumber makes the software testing process easier by allowing the provision of BDD (Behavior Driven Development).
  • It supports the use of different programming languages such as Ruby and .Net.
  • It makes the code reusable as it has a test script structure.
  • It is easy to use and set up.
  • Beneficial for focusing on the end user experiences.
  • It will be useful for increasing the readability of the code as it can be used to write test cases in plain English.

How to run multiple feature files in Cucumber?

This code can be used to run multiple feature files, outline and multicolumn.

package org.softpost;

import Cucumber .api.CucumberOptions;

import Cucumber .api.junit.Cucumber;

import org.junit.runner.RunWith;



        features = {"classpath:multicolumn.feature","classpath:outline.feature"},

        glue = "classpath:org.softpost",

        plugin = "html:target/selenium-reports")

public class MultipleFeatureTest {


How to generate Cucumber reports in eclipse?

The Cucumber reports can be generated in eclipse using different methods. The Pretty report method is a popular choice. It is a plugin that can be used in the Cucumber code. The syntax is given below:

TestRunner. java

package runners;

import org.junit.runner.RunWith;

import Cucumber .api.CucumberOptions;

import Cucumber .api.junit.Cucumber;



 features = "src/test/resources/functionalTests",

 glue= {"stepDefinitions"},

 plugin = { "pretty" },

 monochrome = true


public class TestRunner {


Running this code will result in Eclipse generating an output.

List various keywords which are used in Cucumber in order to write a scenario.

The different keywords used to write a scenario in Cucumber are When, Then, And, Given.

What is feature file in Cucumber and how to create feature file in Cucumber?

Feature files can be considered as the starting points of a Cucumber test. This file is used to write test cases in plain English. It is the high-level description of the Application Under Test (AUT).

Steps to create a feature file:

  • Click on New>File under the Feature folder.
  • Name the file with an extension of .feature. ex-Test.feature
  • Write the Cucumber script

What is BDD Cucumber?

The BDD (Behavior Driven Development) is used to develop applications using plain text or English. It is used for making the code readable to the analysts, quality assurance employees and other stakeholders and it easy to read. Gherkin is the language used for Cucumber.

What are the 2 files required to execute a Cucumber test scenario?

The two files needed to run a test scenario are:

  • Step definition
  • Features

Explain step definitions and how to write step definitions in Cucumber?

The step definition is a piece of code that defines the feature mentioned in the code within the feature file. Every step of the feature file can be linked to a method in the step definition file.

An example of a step definition using Given function is:

To make a person visit the Yahoo site we write,

Given (/^ I am on$/) do

Browser.goto “”


How to run Cucumber tests in parallel?

Parallel tests can be run in Cucumber using the Cucumber JVM Parallel Plugin that can be used with Serenity BDD. The plugin will search for feature files in under the src/test/resources directory. It will then make runners for each file.

How to use tags in Cucumber?

Tags are used in Cucumber to reduce the creation of feature files for running specific tests like Regression Tests and Smoke Tests. By using a tag, we can organize the scenario execution by using a tag inside the feature file. This helps us to choose the scenario that we want to execute.

For example, to define a tag @RegressionTest above the scenarios you want to mark. To target these scenarios, specify  - tags={“@RegressionTests”} in the Cucumber options.

What are hooks in Cucumber?

Hooks are blocks of code that help us to maintain the workflow of the entire code. They run before and after each scenario. They are defined using the @Before and @After methods and can be placed in the step definition layers or anywhere else in the code.

Explain types of Hooks in Cucumber.

The different types of hooks in Cucumber are:

  • Before – This block of code executes before the test scenarios.
  • After - This block of code executes after the test scenarios. 

What are the languages supported by Cucumber -JVM?

The languages that are supported by Cucumber JVM are:

  • Ruby
  • Clojure
  • Scala
  • Groovy

What is the use of dry-run in Cucumber?

The dry run is one of the options in Cucumber that can be set to True or False. If it is set to True, Cucumber will check whether every step in the feature file corresponds to the code written in the Step definition file.