Cucumber Q&A

[vc_row][vc_column css_animation=”fadeInLeft”][vc_column_text css=”.vc_custom_1564391444047{background-color: #1e73be !important;}”]

Cucumber Interview Questions & Answers

[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column css_animation=”fadeInLeft” width=”1/2″][vc_tta_accordion color=”peacoc” active_section=”1″][vc_tta_section title=”What Is Cucumber?” tab_id=”1564391516070-33c07f47-5be7″][vc_column_text]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.[/vc_column_text][/vc_tta_section][vc_tta_section title=”Cucumber Execution Starts From Where?” tab_id=”1564391516085-46220910-a40f”][vc_column_text]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.[/vc_column_text][/vc_tta_section][vc_tta_section title=”What Is Support, Env.rb And Hooks.rb ?” tab_id=”1564391556677-538226ef-1242″][vc_column_text]

  • 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, beforeStep and afterStep hooks.

[/vc_column_text][/vc_tta_section][vc_tta_section title=”What Is Profile In Cucumber?” tab_id=”1564391557292-6ac5c5f2-8d21″][vc_column_text]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[/vc_column_text][/vc_tta_section][vc_tta_section title=”What Are Before, After, Beforestep And Afterstep Hooks?” tab_id=”1564391557903-82e0f25a-72df”][vc_column_text]efore: 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[/vc_column_text][/vc_tta_section][vc_tta_section title=”What Are Cucumber Tags? Why We Use The Tags? ” tab_id=”1564391558795-5024100c-4e7a”][vc_column_text]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>

Ex: cucumber features -t @test[/vc_column_text][/vc_tta_section][vc_tta_section title=”What Is Cucumber Dry Run?” tab_id=”1564391559392-68d17150-c3ef”][vc_column_text]Cucumber dry run is used to compile cucumber feature files and stepDefinitions. If there is any compilations errors it will show when we use dry run

Ex: Cucumber features –dry-run[/vc_column_text][/vc_tta_section][vc_tta_section title=”What Is Scenario Outline?” tab_id=”1564391559859-8deb7613-f2f1″][vc_column_text]Scenario outline is used to execute the same scenario with different test data.[/vc_column_text][/vc_tta_section][vc_tta_section title=” Is It Mandatory To Use The Keywords While Writing Scenario Steps ?” tab_id=”1564391560347-5bab8833-7c25″][vc_column_text]No it is not mandatory to used keywords while writing scenario steps.

We can write the scenario steps like the following without using keywords

* I am on the landed page[/vc_column_text][/vc_tta_section][vc_tta_section title=”How To Generate Cucumber Execution Reports?” tab_id=”1564391560835-ef512395-7c44″][vc_column_text]We can use the following command to generate html reports.

–format html –out report.html –format pretty.[/vc_column_text][/vc_tta_section][vc_tta_section title=”How To Run A Particular Scenario From A Feature File ?” tab_id=”1564391562059-4150db25-f8c8″][vc_column_text]We can run particular scenario from a feature file by giving the scenario line number

Ex: cucumber features/test.feature:21[/vc_column_text][/vc_tta_section][vc_tta_section title=”What Is Cucumber And What Are The Advantages Of Cucumber?” tab_id=”1564391562567-6bad1e5e-c2eb”][vc_column_text]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

[/vc_column_text][/vc_tta_section][vc_tta_section title=”What Are The 2 Files Required To Execute A Cucumber Test Scenario?” tab_id=”1564391563136-f2d6d00e-8610″][vc_column_text]The 2 files required to execute a Cucumber test scenario are

  1. Features
  2. Step Definition

[/vc_column_text][/vc_tta_section][vc_tta_section title=”What Is Feature File In Cucumber? What Does Feature File Consist Of ?” tab_id=”1564391563627-2805cfba-c5ab”][vc_column_text]Feature file in cucumber consist of parameters or conditions required for executing code, they are:

  1. Feature
  2. Scenario
  3. Scenario Outline
  4. Given
  5. When
  6. Then

[/vc_column_text][/vc_tta_section][/vc_tta_accordion][/vc_column][vc_column css_animation=”fadeInRight” width=”1/2″][vc_tta_accordion color=”peacoc” active_section=”1″][vc_tta_section title=”Give An Example Of Behaviour Driven Test In Plain Text?” tab_id=”1564391519772-16b14aec-5330″][vc_column_text]Feature: Visit XYZ page in

Scenario : Visit

Given: I am on

When: I click on XYZ page

Then: I should see ABC page[/vc_column_text][/vc_tta_section][vc_tta_section title=”Explain What Is Scenario Outline In Feature File?” tab_id=”1564391519787-4c6370fd-415f”][vc_column_text]

  1. 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).

[/vc_column_text][/vc_tta_section][vc_tta_section title=”What Is Step Definition In Cucumber?” tab_id=”1564391565803-e9d2e75c-d8fa”][vc_column_text]A step definition is the actual code implementation of the feature mentioned in feature file.[/vc_column_text][/vc_tta_section][vc_tta_section title=”Give The Example For Step Definition Using “given” Function?” tab_id=”1564391566375-ead14924-af41″][vc_column_text]For example to make visitor visit the site “wisdomjobs” the command we use for given:

Given (/^ I am on$/) do

Browser.goto “”

end – This will visit[/vc_column_text][/vc_tta_section][vc_tta_section title=”What Are The Difference Between Jbehave And Cucumber?” tab_id=”1564391566979-8d6ae35f-31fb”][vc_column_text]

  • 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.

[/vc_column_text][/vc_tta_section][vc_tta_section title=”Explain What Is Test Harness?” tab_id=”1564391567419-815f671c-a3d2″][vc_column_text]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.[/vc_column_text][/vc_tta_section][vc_tta_section title=”Explain When To Use Rspec And When To Use Cucumber?” tab_id=”1564391567857-e6578855-f7b4″][vc_column_text]

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


[/vc_column_text][/vc_tta_section][vc_tta_section title=”What Is The Language Used For Expressing Scenario In Feature File ?” tab_id=”1564391569096-d78a3ede-7a70″][vc_column_text]Gherkin language is used to express scenario in feature files and ruby files containing unobtrusive automation for the steps in scenarios.[/vc_column_text][/vc_tta_section][vc_tta_section title=”Explain What Is Regular Expressions?” tab_id=”1564391569568-7d004f74-507f”][vc_column_text]A regular expression is a pattern describing a certain amount of text. The most basic regular expression consists of a single literal character.[/vc_column_text][/vc_tta_section][vc_tta_section title=”Explain What Is Bdd (behaviour Driven Development) ?” tab_id=”1564391570044-f11f899d-2bd6″][vc_column_text]BDD or Behaviour driven development is a process of developing software based on TDD (Test Driven Development) which focusses on behavioural specification of software units.[/vc_column_text][/vc_tta_section][vc_tta_section title=”What Softare Do You Need To Run A Cucumber Web Test?” tab_id=”1564391570499-4478fc0a-3d2c”][vc_column_text]Ruby and its Development Kit
IDE like ActiveState
Watir ( To simulate browser)
Ansicon and rspec (if required)[/vc_column_text][/vc_tta_section][vc_tta_section title=”What Does A Features/ Support File Contains?” tab_id=”1564391570940-e9459783-3e3a”][vc_column_text]Features/ support file contains supporting ruby code. Files in support load before those in step_definitions, which can be useful for environment configuration.[/vc_column_text][/vc_tta_section][vc_tta_section title=”What Is Bdd Framework.what Is The Benefit Of Bdd In Selenium ?” tab_id=”1564391571498-68dc5702-51f0″][vc_column_text]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.[/vc_column_text][/vc_tta_section][/vc_tta_accordion][/vc_column][/vc_row]

WhatsApp us