Cucumber – a Behavior Driven Development (BDD) framework which is used with Selenium for performing acceptance testing.
Cucumber feature files can serve as a good document for all. There are many other tools like JBehave which also support BDD framework. Initially Cucumber was implemented in Ruby and then extended to Java framework. Both the tools support native JUnit.
Behavior Driven Development is extension of Test Driven Development and it is used to test the system rather than testing the particular piece of code. We will discuss more about the BDD and style of writing BDD tests.
Cucumber can be used along with Selenium, Watir, and Capybara etc. Cucumber supports many other languages like Perl, PHP, Python, .Net etc. In this tutorial we will concentrate on Cucumber with Java as a language.
#1) Feature Files:
Feature files are essential part of cucumber which is used to write test automation steps or acceptance tests. This can be used as live document. The steps are the application specification. All the feature files ends with .feature extension.
Sample feature file:
Feature: Login Functionality Feature
============================================
1) 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
2) What are the 2 files required to execute a Cucumber test scenario?
The 2 files required to execute a Cucumber test scenario are
Features
Step Definition
3) 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
Feature
Scenario
Scenario Outline
Given
When
Then
4) Give an example of behaviour driven test in plain text?
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
5) 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).
6) What is step definition in Cucumber?
A step definition is the actual code implementation of the feature mentioned in feature file.
061114_1018_Introductio1
7) 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
Browser.goto “http://www.yahoo.com”
end – This will visit www.yahoo.com
8) 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
9) 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
10) 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
11) 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
12) 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
13) 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.
14) What softare do you need to run a Cucumber Web Test ?
Ruby and its Development Kit
Cucumber
IDE like ActiveState
Watir ( To simulate browser)
Ansicon and rspec (if required)
15) 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.
Cucumber Introduction:
Cucumber is a tool based on Behavior Driven Development (BDD) framework which is used to write acceptance tests for web application. It allows automation of functional validation in easily readable and understandable format (like plain English) to Business Analysts, Developers, Testers, etc.Cucumber feature files can serve as a good document for all. There are many other tools like JBehave which also support BDD framework. Initially Cucumber was implemented in Ruby and then extended to Java framework. Both the tools support native JUnit.
Behavior Driven Development is extension of Test Driven Development and it is used to test the system rather than testing the particular piece of code. We will discuss more about the BDD and style of writing BDD tests.
Cucumber can be used along with Selenium, Watir, and Capybara etc. Cucumber supports many other languages like Perl, PHP, Python, .Net etc. In this tutorial we will concentrate on Cucumber with Java as a language.
Cucumber Basics:
In order to understand cucumber we need to know all the features of cucumber and its usage.#1) Feature Files:
Feature files are essential part of cucumber which is used to write test automation steps or acceptance tests. This can be used as live document. The steps are the application specification. All the feature files ends with .feature extension.
Sample feature file:
Feature: Login Functionality Feature
In order to ensure Login Functionality works,
I want to run the cucumber test to verify it is working
Scenario: Login FunctionalityI want to run the cucumber test to verify it is working
Given user navigates to SOFTWARETETINGHELP.COM
When user logs in using Username as “USER” and Password “PASSWORD”
Then login should be successful
Scenario: Login FunctionalityWhen user logs in using Username as “USER” and Password “PASSWORD”
Then login should be successful
Given user navigates to SOFTWARETETINGHELP.COM
When user logs in using Username as “USER1” and Password “PASSWORD1”
Then error message should be thrown
When user logs in using Username as “USER1” and Password “PASSWORD1”
Then error message should be thrown
============================================
1) 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
2) What are the 2 files required to execute a Cucumber test scenario?
The 2 files required to execute a Cucumber test scenario are
Features
Step Definition
3) 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
Feature
Scenario
Scenario Outline
Given
When
Then
4) Give an example of behaviour driven test in plain text?
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
5) 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).
6) What is step definition in Cucumber?
A step definition is the actual code implementation of the feature mentioned in feature file.
061114_1018_Introductio1
7) 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
Browser.goto “http://www.yahoo.com”
end – This will visit www.yahoo.com
8) 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
9) 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
10) 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
11) 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
12) 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
13) 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.
14) What softare do you need to run a Cucumber Web Test ?
Ruby and its Development Kit
Cucumber
IDE like ActiveState
Watir ( To simulate browser)
Ansicon and rspec (if required)
15) 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.
awesome post presented by you..your writing style is fabulous and keep update with your blogs Big data hadoop online training India
ReplyDeleteExcellent!! You provided very useful information in this article. I have read many articles in various sites but this article is giving in depth explanation about Ruby Cucumber Training . Recently, I also took training on this “Ruby Cucumber Training Hyderabad '' from Excelr.
ReplyDeleteRuby Cucumber Training Hyderabad
Ruby on rails are concepts are clearly explained
ReplyDeleteManual Testing Training in Chennai
QTP Training in Chennai
Selenium Training in Chennai
SoapUI Training in Chennai
Software Testing Training in Chennai