25+ [ SURE SHOT ] Ruby Cucumber Interview Questions & Answers
Ruby Cucumber Interview Questions and Answers

25+ [ SURE SHOT ] Ruby Cucumber Interview Questions & Answers

Last updated on 04th Jul 2020, Blog, Interview Questions

About author

Ramkumar (Sr Project Manager )

(5.0) | 15212 Ratings 1301

Getting Started with Cucumber Ruby and CrossBrowserTesting

Cucumber provides language-bindings for the powerful browser-driving tool Selenium. Its Gherkin language allows you to write your tests in a way that can be easily read by anyone on your team.

1) How Does Cucumber Works With Browser Automation?


Cucumber does not provide built in browser automation. However, it does work well with existing gems such as Selenium and WATiR-WebDriver.[24] It does support running tests with transactions through leveraging other gems such as ActiveRecord.

2) What Are Formatter Plugins In Cucumber?


Cucumber uses Formatter Plugins to provide output. Several common formats are provided by default, including

  • JSON
  • HTML
  • JUnit

3) What Are Hooks In Cucumber?


Hooks are Cucumber’s way of allowing for setup to be performed prior to tests being run and teardown to be run afterward. They are defined as executable Ruby blocks, similar to JUnit methods marked with @Before, @After annotations. Conventionally they are placed under support/, and are applied globally. Three basic types of hooks exist.
Before – Runs before a scenario
After – Runs after a scenario
Around – Assumes control and runs around a scenario
Additional hooks include

  • BeforeStep
  • AfterStep
  • AfterConfiguration – Runs after Cucumber configuration and is passed an instance of the configuration

4) What Are Steps In Cucumber?


Steps in Gherkin’s .feature files can be considered a method invocation. Before Cucumber can execute a step it must be told, via a step definition, how that step should be performed.
Definitions are written in Ruby and conventionally filed under features/step_definitions/*_steps.rb. Definitions start with the same keywords as their invocation (including Gherkin’s full language support). Each definition takes two arguments.
Either a regular expression or string with $variables
A block containing ruby code to execute

5) What Are Tags In Cucumber?


Gherkin’s Feature structure forces organization. However, in cases where this default organization is inconvenient or insufficient, Gherkin provides Tags. Tags are @-prefixed strings and can be placed before.

  • Feature
  • Scenario
  • Scenario Outline
  • Examples: An element can have multiple tags and inherits from parent elements.

6) What Is A Scenario In Cucumber?


Each Feature is made of a collection of scenarios. A single scenario is a flow of events through the Feature being described and maps 1:1 with an executable test case for the system.[18] Keeping with the example ATM withdrawal feature, a scenario might describe how a user requests money and what happens to their account.

7) What Is A Feature In Cucumber?


A feature is a Use Case that describes a specific function of the software being tested. There are three parts to a Feature [18]

  • The Feature: keyword
  • The Feature name (on the same line as the keyword)
  • An optional description on the following lines

8) Cucumber Tests Are Divided Into How Many Parts?


Cucumber tests are divided into individual Features. These Features are subdivided into Scenarios, which are sequences of Steps.

9) Gherkins Files Have Which File Extension?


All Gherkin files have the .feature file extension. They contain a single Feature definition for the system under test and are an executable test script.

10) Cucumber Is Written In Which Programming Language?


Cucumber is written in the Ruby programming language. It was originally used exclusively for Ruby testing as a complement to the RSpec BDD framework. Cucumber now supports a variety of different programming languages through various implementations.

11) What Is Gherkin Language?


Gherkin is the language that Cucumber uses to define test cases. It is designed to be non-technical and human readable, and collectively describes use cases relating to a software system.
The purpose behind Gherkin’s syntax is to promote Behavior Driven Development practices across an entire development team, including business analysts and managers.

12) What Is Cucumber Tool?


Cucumber is a software tool used by computer programmers for testing other software. It runs automated acceptance tests written in a behavior-driven development style. Central to the Cucumber BDD approach is its plain language parser called Gherkin.

13) There Are Three Ways To Invoke A Method In Ruby. Can You Give Me At Least Two? Here, I’m Looking For The Dot Operator (or Period Operator), The Object#send Method, Or Method(:foo).call?


object = Object.new
puts object.object_id
#=> 282660
puts object.send(:object_id)
#=> 282660
puts object.method(:object_id).call # (Kudos to Ezra)
#=> 282660

14) What Is Profile In Cucumber?


We can create Cucumber profiles to run specific features and step definitions
We can use following command to execute a cucumber profile
cucumber features -p <profile_name>
Ex: cucumber features -p regression

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


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

16) Cucumber Execution Starts From Where?


Cucumber execution will starts from support. In support first it will load the env.rb file then it will load hooks.rb and then it will start execute feature file scenario steps.

17) 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 following command to execute a cucumber tagged scenarios
cucumber features -t @<tag_name>

18) Define What Are The Benefits?


  • It is helpful to involve business stakeholders who can’t easily read code
  • Cucumber focuses on end-user experience
  • Style of writing tests allow for easier reuse of code in the tests
  • Quick and easy set up and execution
  • Efficient tool for testing

19) Define Cucumber Report?


Cucumber generates its own html format. Define However better reporting can be done using Jenkins or bamboo tool. Details of reporting are covered in next topic of cucumber.

20) Define What Is The Difference Between Class And Module?


P141, P142
Class can do: inheritance, having instance, while module CAN NOT. Can be required.
Module can do: make namespace to avoid name clash, can be included.
#instantiate from class within module
Module A
Class B
b= A::B.new

    Subscribe For Free Demo

    21) Define What Is Error Handling And Define How Do You Do Error Handling?


    P584: Raise, Rescue

    22) Define What Is Bdd Framework.define What Is The Benefit Of Bdd In Selenium ?


    BDD is becoming widely accepted practice in agile software development, and Cucumber-JVM is a mainstream tool used to implement this practice in Java. Cucumber-JVM is based on Cucumber framework, widely used in Ruby on Rails world as well as in Java and .Net.
    Cucumber-JVM allows developers, QA, and non-technical or business participants to write features and scenarios in a plain text file using Gherkin language with minimal restrictions about grammar in a typical Given, When, and Then structure.
    The feature file is then supported by a step definition file, which implements automated steps to execute the scenarios written in a feature file. Apart from testing APIs with Cucumber-JVM, we can also test UI level tests by combining Selenium WebDriver.

    23) Define What Software Do You Need To Run A Cucumber Web Test ?


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

    24) Define What Does A Features/ Support File Contains?


    Features/ support file contains supporting ruby code. Files in support load before those in step_definitions, which can be useful for environment configuration.

    25) Explain Define 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.

    26) Define What Is The Language Used For Expressing Scenario In Feature File ?


    Gherkin language is used to express scenario in feature files and ruby files containing unobtrusive automation for the steps in scenarios

    27) Explain When To Use Rspec And When To Use Cucumber?


    • Rspec is used for Unit Testing
    • Cucumber is used behaviour driven development.
    • Cucumber can be used for System and Integration Tests

    28) Explain Define 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

    29) Define What Are The Difference Between Jbehave And Cucumber?


    Although Cucumber and Jbehave are meant for the same purpose, acceptance tests are completely different frameworks

    • Jbehave is Java based and Cucumber is Ruby based
    • Jbehave are based on stories while Cucumber is based on features

    30) Define What Is Step Definition In Cucumber?


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

    Course Curriculum

    Learn Ruby Cucumber Training From Experienced Instructors

    Weekday / Weekend BatchesSee Batch Details

    31) Explain Define 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).

    32) Give An Example Of Behaviour Driven Test In Plain Text?


    Feature:Visit XYZ page in abc.com
    Scenario:Visit abc.com
    Given:I am on abc.com
    When:I click on XYZ page
    Then:I should see ABC page

    33) Define What Is Cucumber And Define What Are The Advantages Of Cucumber?


    To run functional tests written in a plain text Cucumber tool is used. It is written in a Ruby programming language.
    Advantages of Cucumber

    • You can inolve business stakeholders who can not code
    • End user experience is priority
    • High code reuse

    34) Define How To Generate Cucumber Execution Reports ?


    We can use the following command to generate html reports.

    –format html –out report.html –format pretty

    35) Define What Are The Keywords That We Use In Cucumber Scenario Steps ?


    We use Given,when,Then,And and But keywords in cucumber scenario steps .

    36) Define What Is Scenario Outline ?


    Scenario outline is used to execute the same scenario with different test data.we will add test data in examples section

    37) How To Run A Particular Scenario From A Feature File?


    We can run particular scenario from a feature file by giving the scenario line number

    Ex: cucumber features/test.feature:21

    38) Define What Is Cucumber Dry Run ?


    Cucumber dry run is used to compile cucumber feature files and step Definitions. Of there is any compilations errors it will Define How when we use dry run 

    Ex: Cucumber features –dry-run

    39)  Define 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

    40) Define What Is Profile In Cucumber ?


    We can create Cucumber profiles to run specific features and step definitions

    We can use following command to execute a cucumber profile

    cucumber features -p <profile_name>

    Ex: cucumber features -p regression

    41) What is cucumber.yml file in cucumber ?


    In cucumber.yml file we will create profiles

    we will add test data in examples section

    42) How to run a particular scenario from a feature file ?


    We can run particular scenario from a feature file by giving the scenario line number

    Ex: cucumber features/test.feature:21

    Let us move to the next Cucumber interview question.

    Course Curriculum

    Get JOB Oriented Ruby Cucumber Training By Experienced Instructors

    • Instructor-led Sessions
    • Real-life Case Studies
    • Assignments
    Explore Curriculum

    43) What are the features in Cucumber?


    This is the most common cucumber interview questions. A feature can be defined as a unit or functionality or part of a project which is an independent functionality of the project. A feature contains a group of scenarios which are to be tested as a feature. There are two parts in a feature in Cucumber tool which is called feature files having scenarios in it and the feature files containing automation steps or procedure to be executed. An example of a feature can be a login functionality of a website or chat functionality of a website, a news feed of a website etc.

    44) What is a feature file in Cucumber?


    A feature file in Cucumber is a starting point of the Cucumber tests execution. This is the basic cucumber interview questions. The feature files exist in the feature folder. To add a feature file in the project, the scenario or feature to be automated has to be identified before, then feature file is added and then test runner class will be created. Now step definitions have to be linked with feature files. The scenario steps will then be executed during automation. In this file, the description of the tests will be available in the descriptive language. A feature file can have a single or multiple scenarios but normally it contains a group of scenarios. The feature file format will be like file_name. a feature where a single file contains a single feature

    45) What is a test framework?


    In general, a framework is an entity that binds several modules in a logical sequence to cover the end-to-end flows of an application. The objective of investing in a framework is to test a product that has a recurring roadmap and a regular release cycle.

    46) What are the apparent advantages of a test framework?


    The following are the possible benefits of using a test framework.

    1- It reduces the complexity of using a variety of technologies inculcated in a product.

    2- It organizes the unit and functional testing efforts of a developer and tester.

    3- Provides early feedback on the quality of the code.

    4- Helps in tracking test coverage as well as code coverage.

    5- Results in easy debugging and reduces the chances of errors.

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


    Support is a foder 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, before step and after step hooks.

    48) Explain about and, but keywords in Cucumber?


    “And” is used to combine two or more same type of action.

    Cucumber steps beginning with “And” or “But” are exactly the same as all other steps.


          Given one thing

          And another thing

          When I open my eyes

          Then I see something

          But I don’t see anything else

    49) What do you mean by grouping in Cucumber?


    Cucumber will not take care how you name your step definition files and what step definitions you put in which file.

    You can create steps.rb file for each Major operation / Features instead of keeping all steps in a single file. This process is called a grouping.


    Under features folder



    50) What is the difference between cucumber, JBehave, and Specflow?


    Cucumber is a Ruby based framework

    JBehave is a JAVA based framework

    Specflow is a .NET based framework

    51) What software do you need to run cucumber in JAVA?


    Eclipse or IntelliJ IDE

    Gradle or Maven build tool

    Junit or TestNG testing framework


    Selenium (To automate browser)

    Ruby Cucumber Sample Resumes! Download & Edit, Get Noticed by Top Employers! Download

    52) Explain test harness in Cucumber?


    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.

    53) What are the differences between JBehave and Cucumber?


    Although Cucumber and JBehave are meant for the same purpose, acceptance tests are completely different frameworks:

    JBehave is pure Java Framework, and Cucumber is Ruby-based.

    JBehave are based on stories while Cucumber is based on features.

    54) In what ways does the Cucumber execution start? What are the variously advanced frameworks used with the Cucumber development tool?  


    Support is the place from where the execution of Cucumber test starts. The software which requires testing is mainly prioritized by the Cucumber software development tool. For the execution of the process of testing, the file gets loaded at first in Support and it is generally the env.rb file. Then the hooks.rb file gets loaded. Finally, the steps of the scenarios get executed from the feature file. Cucumber testing tool executes its work with the help of all these folders, commands and keywords. Support is considered to be very important in this respect. 

    The following are the advancement frameworks available with the Cucumber tools –  

    1. Page Object Model  

    2. Object Repository 

    3. Extent Reporting  

    4. Dependency Injection 

    5. Log4j

    55) What are the different JARs that can be used to integrate Cucumber testing tool?


    Following Cucumber JARs can be used for integration:

    • cucumber-core-1.2.2.jar
    • cucumber-junit-1.2.2.jar
    • cucumber-java-1.2.2.jar
    • cucumber-jvm-deps-1.0.3.jar
    • cucumber-reporting-0.1.0.jar
    • gherkin-2.12.2.jar

    56) Which plugin is used to integrate Eclipse with Cucumber testing tool?


    Cucumber Natural Plugin is the plugin that is used to integrate Eclipse with Cucumber.

    57) What is the use of TestRunner class in Cucumber testing tool?


    TestRunner class is used to provide the link between feature file and step definition file.

    58) In Cucumber testing tool what is the starting point of execution for feature files?


    When integrated with Selenium, the starting point of execution must be from TestRunner class.

    Are you looking training with Right Jobs?

    Contact Us
    Get Training Quote for Free