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.
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.
Ans:
Ans:
Ex: cucumber features -p regression
Ans:
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
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
Ans: We can run particular scenario from a feature file by giving the scenario line number
Ex: cucumber features/test.feature:21
Ans: We use Given,when,Then,And and But keywords in cucumber 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
Ans: We can use the following command to generate html reports.
–format html –out report.html –format pretty
Ans: We can run particular scenario from a feature file by giving the scenario line number
Ex: cucumber features/test.feature:21
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
Ans: The 2 files required to execute a Cucumber test scenario are
Ans: Feature file in cucumber consist of parameters or conditions required for executing code, they are
Ans:
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).
Ans: A step definition is the actual code implementation of the feature mentioned in feature file.
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
Ans: Although Cucumber and Jbehave are meant for the same purpose, acceptance tests are completely different frameworks
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
Ans: Rspec is used for Unit Testing
Cucumber is used behaviour driven development.
Cucumber can be used forSystem and Integration Tests
Ans: Gherkin language is used to express scenario in feature files and ruby files containing unobtrusive automation for the steps in scenarios
Ans: A regular expression is a pattern describing a certain amount of text. The most basic regular expression consists of a single literal character
Ans: in cucumber.yml file we will create profiles
Ans:
Ans: Features/ support file contains supporting ruby code. Files in support load before those in step_definitions, which can be useful for environment configuration.
Ans:
Ans: P42, interpolation. most case used as puts “#{x} + #{y}” = “#{x+y}”
Ans: P584: Raise, Rescue
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
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.
Ans:
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>
Ans: Features/ support file contains supporting ruby code. Files in support load before those in step_definitions, which can be useful for environment configuration.
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.
Ans:
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
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