Cucumber Interview Questions and Answers
1) What Is Cucumber?
Cucumber is a Behavior Driven Development (BDD) tool. Cucumber is a tool that executes plain-text functional descriptions as automated tests. The language that Cucumber understands is called Gherkin.
In BDD, users (business analysts, product owners) first write scenarios or acceptance tests that describes the behavior of the system from the customer’s perspective, for review and sign-off by the product owners before developers write their codes.
2) What is Behavior Driven Development (BDD)?
BDD is a way for software teams to work that closes the gap between business people and technical people by:
> Encouraging collaboration across roles to build shared understanding of the the problem to be solved
> Working in rapid, small iterations to increase feedback and the flow of value
> Producing system documentation that is automatically checked against the system’s behaviour
BDD and Agile
We assume that your team are using some kind of agile methodology already, planning work in small increments of value like User Stories. BDD does not replace your existing agile process, it enhances it.
3) What language is used by Cucumber?
Gherkin is the language that is used by the Cucumber tool. It is a simple English representation of the application behavior. Gherkin language uses several keywords to describe the behavior of application such as Feature, Scenario, Scenario Outline, Given, When, Then etc.
4) 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.
A feature file may include multiple scenarios within the same file. A feature file has the extension .feature.
5) What are the different keywords used in feature file?
The different keywords used in the feature file are Feature, Background, Scenario, Scenario Outline, Given, When, Then and But. The keyword used to represent a feature in a feature file is Feature. The feature file should be mentioned with a brief description to ensure the best practice standards. A Feature is the Name of the feature that is under test, Description is about the feature under test, Scenario is about What the test scenario is, Given is Prerequisite before the test steps get executed, When is a specific condition that matches in order to execute the next step, Then is about What happens if the condition in WHEN is satisfied
6) What is the purpose of Scenario Outline in Cucumber?
Scenario outline is a way of parameterization of scenarios. This is ideally used when the same scenario needs to be executed for multiple sets of data, however, the test steps remain the same. Scenario Outline must be followed by the keyword ‘Examples’, which specify the set of values for each parameter.
7) What is a profile in Cucumber?
Cucumber profiles can be created in the project to make the configurations. A default profile will always be available in the project. The configuration file will be like cucumber.yml file where the profiles will be configured. The data types and parameter types can be configured using the type registry. The profiles or default profiles will not be available in Java.
8) What are the major advantages of Cucumber framework?
> Cucumber is an open source tool.
> Plain Text representation makes it easier for non-technical users to understand the scenarios.
> It bridges the communication gap between various project stakeholders such as Business Analysts, Developers, and Quality Assurance personnel.
> Automation test cases developed using the Cucumber tool are easier to maintain and understand as well.
> Easy to integrate with other tools such as Selenium and Capybara.
9) How you will comment in Cucumber?
Cucumber allows you to precede Feature and Scenario keywords with comments.
Comments will be denoted with #
10) What are the two files required to execute a Cucumber Test Scenario?
Two files required to execute a Cucumber test scenario are
ii. Step Definition
11) What software do you need to run a Cucumber Web Test Cases?
i. Ruby and its Development Kit
iii. IDE like ActiveState
iv Watir ( To simulate browser)
v) Ansicon and rspec (if required)
12) Cucumber also works with the Browser Automation, How?
Cucumber tool works with browsers like Selenium and WATIR-WebDriver. Build in browser automation is not available in the Cucumber tool. It also works with another type of browser like the Active record by supporting their tests.
13) Differentiate between Jbehave and Cucumber?
Cucumber tool and Jbehave have the same reason to be used by a user however they are built by the different framework –
i. Jbehave is based on Java whereas Cucumber is based on Ruby programming language.
ii. Stories make the base of Jbehave whereas features make the base of Cucumber tool.