Q. What is Cucumber and 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
Q. What are the 2 files required to execute a Cucumber test scenario?
The 2 files required to execute a Cucumber test scenario are
Q. What is feature file in Cucumber? What does feature file consist of ?
Feature file in cucumber consist of parameters or conditions required for executing code, they are
Q. Give an example of behaviour driven test in plain text?
Feature: VisitXYZ 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
Q. 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).
Q. What is step definition in Cucumber?
A step definition is the actual code implementation of the feature mentioned in feature file.
Q. Give the example for step definition using “Given” function?
For example to make visitor visit the site “Yahoo” the command we use for given
Given (/^ I am on www.yahoo.com$/) do
end – This will visit www.yahoo.com
Q. 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
Q. 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
Q. 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
Q. 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
Q. 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
Q. Explain what is BDD (Behaviour Driven Development)?
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.
Q. What softare 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)
Q. 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.
Q. 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.
Q. 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, beforeStep and afterStep hooks
Q. 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
Ex: cucumber features -p regression
Q. What is cucumber.yml file in cucumber?
in cucumber.yml file we will create profiles
Q. 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
Q. 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 @
Ex: cucumber features -t @TEST
Q. What is cucumber dry run?
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
Q. What is scenario outline?
Scenario outline is used to execute the same scenario with different test data.
Q. What are the keywords that we use in cucumber scenario steps?
We use Given,when,Then,And and But keywords in cucumber scenario steps
Q. Is it mandatory to use the keywords while writing scenario steps?
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
Q. How to generate cucumber execution reports?
We can use the following command to generate html reports.
–format html –out report.html –format pretty
Q. 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
Get Updates on Tech posts, Interview & Certification questions and training schedules