Corporate Training
Request Demo
Click me
Menu
Let's Talk
Request Demo

Ruby Cucumber Interview Questions

by Venkatesan M, on May 17, 2017 11:38:38 PM

Ruby Cucumber Interview Questions

Q1. Define what is Cucumber?

Ans: 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.

Q2. Cucumber execution starts from where ?

Ans: 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.

Q3. Define what is support, env.rb and hooks.rb ?

Ans:

  • 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

Q4. Define what is profile in cucumber ?

Ans: 

  • 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

Q5. Define what are before, after, beforeStep and afterStep hooks?

Ans: 

  • 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

Q6. Define what are cucumber tags? why we use the tags ?

Ans: 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

Q7. Define what is cucumber dry run ?

Ans: Cucumber dry run is used to compile cucumber feature files and stepDefinitions. If there is any compilations errors it will sDefine How when we use dry run

Ex: Cucumber features –dry-run

Q8. How to run a particular scenario from a feature file?

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

Ex: cucumber features/test.feature:21

Q9. Define what is scenario outline ?

  • we will add test data in examples section

Q10. Define what are the keywords that we use in cucumber scenario steps ?

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

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

 

Q12. Define How to generate cucumber execution reports ?

Ans: We can use the following command to generate html reports.

–format html –out report.html –format pretty

Q13. Define How to run a particular scenario from a feature file ?

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

Ex: cucumber features/test.feature:21

Q14. Define what is Cucumber and Define what are the advantages of Cucumber?

Ans: 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

Q15. Define what are the 2 files required to execute a Cucumber test scenario?

Ans: The 2 files required to execute a Cucumber test scenario are

  1. Features
  2. Step Definition

Q16. Define what is feature file in Cucumber? Define what does feature file consist of ?

Ans: Feature file in cucumber consist of parameters or conditions required for executing code, they are

  • Feature
  • Scenario
  • Scenario Outline
  • Given
  • When
  • Then

Q17. Give an example of behaviour driven test in plain text?

Ans: 

  • 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

Q18. Explain Define what is Scenario Outline in feature file?

Ans: 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).

Q19. Define what is step definition in Cucumber?

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

Q20. Give the example for step definition using “Given” function?

Ans: For example to make visitor visit the site “Yahoo” the command we use for given

Given (/^ I am on www.yahoo.com$/) do

Browser.goto “http://www.yahoo.com”

end – This will visit www.yahoo.com

Q21. Define what are the difference between Jbehave and Cucumber?

Ans: 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

Q22. Explain Define what is test harness?

Ans: 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

Q23. Explain when to use Rspec and when to use Cucumber?

Ans: Rspec is used for Unit Testing

Cucumber is used behaviour driven development.

Cucumber can be used forSystem and Integration Tests

Q24. Define what is the language used for expressing scenario in feature file ?

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

Q25. Explain Define what is regular expressions?

Ans: A regular expression is a pattern describing a certain amount of text. The most basic regular expression consists of a single literal character

Q26. Define what is cucumber.yml file in cucumber ?

Ans: in cucumber.yml file we will create profiles

Q27. Define what softare do you need to run a Cucumber Web Test ?

Ans: 

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

Q28. Define what does a features/ support file contains ?

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

Q29. Define what is BDD Framework.Define what is the benefit of BDD in selenium ?

Ans: 

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

Q30. Define what is #{} and Define How do you use it?

Ans: P42, interpolation. most case used as puts “#{x} + #{y}” = “#{x+y}”

Q31. Define what is error handling and Define How do you do error handling?

Ans: P584: Raise, Rescue

Q32. Define what is the difference between class and module?

Ans: 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
End
b= A::B.new

Q33. Define Cucumber Report:

Ans: 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.

Q34. Define what are the benefits?

Ans: 

  • 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

Q35. What are cucumber tags? why we use the tags?

Ans: 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>

Q36. What does a features/ support file contains?

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

Q37. Cucumber execution starts from where?

Ans: 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.

Q38. What is support, env.rb and hooks.rb ?

Ans: 

  • 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

Q39. What is profile in cucumber?

Ans: 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

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

Ans: object = Object.new

puts object.object_id

#=> 282660

puts object.send(:object_id)

#=> 282660

puts object.method(:object_id).call # (Kudos to Ezra)

#=> 282660

Topics:ruby cucumberruby cucumber interview questionsInformation Technologies (IT)

Comments

Subscribe

Top Courses in Python

Top Courses in Python

We help you to choose the right Python career Path at myTectra. Here are the top courses in Python one can select. Learn More →

aathirai cut mango pickle

More...