SlideShare a Scribd company logo
1 of 15
Download to read offline
By Mithilesh Singh
Cucumber
Behavioral Driven Development
(BDD) is a software development
approach. It differs by being
written in a shared language,
which improves communication
between tech and non-tech teams
and stakeholders.
BDD
Why we use
BDD
• Let’s assume there is a requirement from a client for
an E Commerce website to increase the sales of the
product with implementing some new features on
the website, the only challenge of the development
team is to convert the client idea in to something
that actually delivers the benefits to client, The
origin idea is awesome but the only challenge here is
that the person who is developing the idea is not the
same person is not the same person who has that
idea. If the person who has the idea happens to be a
talented software developer. Then we might be in
luck the idea could be turned into working software
without even needing to be explained to anyone
else. Now the idea needs to be communicated and
has to travel from the business owner(client) to the
development team.
Note: Cucumber helps to improve communication
between technicalandnon-technicalmembersin the
same project
Gherkin
Keywords
* Feature.
* Scenario.
* Given.
*When.
*Then.
*And.
* Background
* Feature : Each Gherkinfile beginswith a Feature keyword.
Feature defines the logicaltest functionality
you willtest in this feature file
* Background : Backgroundkeywordis used to define steps that
are common to allthe tests in the feature file.
* Given : It is nothingbut precondition
*When : keyworddefinesthe test actionthat will be executed.
*Then : verificationofthe output with expected result
* And : keywordis used to add conditionsto your steps.
* But : Use to give negative type comments.
Difference between testNg explanation andCucumber explanation of a scenario
TestNg :
@Test
Public void testAdminUserCanUpdateUserAccPswd(){
// Create Users
User userAdmin = new User(UserRole.ADMIN, userName, Password);
Use admin user to update another user password
String message = userAdmin.updatePassword(user,user_new_password);
//Verify password changed
Assert.assertEquals(message,”password changed successfully”);
Assert. assertEquals(user.getPassword(), user_new_password);
}
Cucumber:
Feature : Update password
Scenario : Admin user can update the user password
Given : I am in the HR system with an admin account
When : I have updated passwordof the another user
Then : I receive a messagefor updating passwordsuccessfully
And : User’s password is updated to the new password.
Options available in cucumber:
dryRun : true : checks if all the feature file steps have created step
false: default condition
Features : set: the path of the feature file.
glue : set: the path of step definition file
tags : instruct: what tags in the feature file should be executed.
monochrome : true: display the console output in much readable way
format : set: different report format which we can use. E.g. html, json.
A. “Pretty” --print the gherkin source with additional colors
format={“pretty”}.
B. HTML : this will help to generate HTMLreports at the
location mentioned in the formatter itself.
format = {“html:Folder_Name”}.
C. Json : this report contains all the information from
the gherkin source in json
format={“json:Folder_Name/cucumber.json”}.
Notes
• 1.Cucumber options we always keep under the
@CucumberOptions annotation under the test runner class inside
our framework.
E.g.
@CucumberOptions(
features = "src/test/resources/features",
glue = "com/demo/qa/ui/steps",
tags = "not @ignore"
dryRun= true)
Components of the Cucumber framework:
1. Feature file
Scenariooutline : verify updating user passwordfeature.
Given : I am in the HR system with “<account_type>”account
And : There is another user with “<old_password>” password
When : I Update password of the user to “<new_password>”
Then : I got the message“<message>”
And : the user password should be “<final_password>”
2. Step definitionfile:
It is a smallpieceof code with a pattern attached to it.
Or
It is a java method in a classwith an annotation above it.
Note: Cucumber findsthe step definitionfilewith the help of glue code in
cucumber option.
3. RunnerClass:To execute the case we need cucumber test
runner class.
Data Driven Approach in Cucumber Framework:
A. parameterization without
an example keyword.
Scenario: Gmail login Test scenario
• Given User is already in login page
• WhenTitle of login page is Gmail
• Then user enters “ABC”and “test@123”
• Then user clicks on login button
• Then user is on home page
Note: we can not test for different no of test
inputs in this approach.To overcome this we have
to go with the approach 2
B. parameterization with example keyword
https://www.facebook.com/Testers-Zone-107916170837875/
Maven
Dependency
for Cucumber
CucumberWorkFlow
https://www.facebook.com/Testers-Zone-107916170837875/

More Related Content

Similar to Cucumber Basics.pdf

Write your first WordPress plugin
Write your first WordPress pluginWrite your first WordPress plugin
Write your first WordPress plugin
Anthony Montalbano
 
Code Camp Applying Modern Software Development Techniques To Ui Testing
Code Camp  Applying Modern Software Development Techniques To Ui TestingCode Camp  Applying Modern Software Development Techniques To Ui Testing
Code Camp Applying Modern Software Development Techniques To Ui Testing
ChristopherGTaylor
 
Vpd Virtual Private Database By Saurabh
Vpd   Virtual Private Database By SaurabhVpd   Virtual Private Database By Saurabh
Vpd Virtual Private Database By Saurabh
guestd83b546
 
LearningMVCWithLINQToSQL
LearningMVCWithLINQToSQLLearningMVCWithLINQToSQL
LearningMVCWithLINQToSQL
Akhil Mittal
 
Cis 407 i lab 6 of 7
Cis 407 i lab 6 of 7Cis 407 i lab 6 of 7
Cis 407 i lab 6 of 7
helpido9
 
need help completing week 6 ilab.. i will upload what I currently ha.docx
need help completing week 6 ilab.. i will upload what I currently ha.docxneed help completing week 6 ilab.. i will upload what I currently ha.docx
need help completing week 6 ilab.. i will upload what I currently ha.docx
niraj57
 

Similar to Cucumber Basics.pdf (20)

Rails Plugins - Linux For You, March 2011 Issue
Rails Plugins - Linux For You, March 2011 IssueRails Plugins - Linux For You, March 2011 Issue
Rails Plugins - Linux For You, March 2011 Issue
 
Write your first WordPress plugin
Write your first WordPress pluginWrite your first WordPress plugin
Write your first WordPress plugin
 
Code Camp Applying Modern Software Development Techniques To Ui Testing
Code Camp  Applying Modern Software Development Techniques To Ui TestingCode Camp  Applying Modern Software Development Techniques To Ui Testing
Code Camp Applying Modern Software Development Techniques To Ui Testing
 
Behavior Driven Development by Example
Behavior Driven Development by ExampleBehavior Driven Development by Example
Behavior Driven Development by Example
 
Vpd Virtual Private Database By Saurabh
Vpd   Virtual Private Database By SaurabhVpd   Virtual Private Database By Saurabh
Vpd Virtual Private Database By Saurabh
 
LearningMVCWithLINQToSQL
LearningMVCWithLINQToSQLLearningMVCWithLINQToSQL
LearningMVCWithLINQToSQL
 
Spring-18 Internship at INSZoom
Spring-18 Internship at INSZoomSpring-18 Internship at INSZoom
Spring-18 Internship at INSZoom
 
Centralizing users’ authentication at Active Directory level 
Centralizing users’ authentication at Active Directory level Centralizing users’ authentication at Active Directory level 
Centralizing users’ authentication at Active Directory level 
 
Automation frameworks
Automation frameworksAutomation frameworks
Automation frameworks
 
Two scoopsofdjango ch16 dealing with the user model
Two scoopsofdjango ch16   dealing with the user modelTwo scoopsofdjango ch16   dealing with the user model
Two scoopsofdjango ch16 dealing with the user model
 
maXbox Starter 43 Work with Code Metrics ISO Standard
maXbox Starter 43 Work with Code Metrics ISO StandardmaXbox Starter 43 Work with Code Metrics ISO Standard
maXbox Starter 43 Work with Code Metrics ISO Standard
 
Comparison of different access controls
Comparison of different access controlsComparison of different access controls
Comparison of different access controls
 
State management servlet
State management servletState management servlet
State management servlet
 
Cis 407 i lab 6 of 7
Cis 407 i lab 6 of 7Cis 407 i lab 6 of 7
Cis 407 i lab 6 of 7
 
Devise and Rails
Devise and RailsDevise and Rails
Devise and Rails
 
Designing Modules in Python
Designing Modules in PythonDesigning Modules in Python
Designing Modules in Python
 
Acceptance tests
Acceptance testsAcceptance tests
Acceptance tests
 
Tightly coupled view (model bounded view)
Tightly coupled view (model bounded view)Tightly coupled view (model bounded view)
Tightly coupled view (model bounded view)
 
need help completing week 6 ilab.. i will upload what I currently ha.docx
need help completing week 6 ilab.. i will upload what I currently ha.docxneed help completing week 6 ilab.. i will upload what I currently ha.docx
need help completing week 6 ilab.. i will upload what I currently ha.docx
 
Wordpress as a framework
Wordpress as a frameworkWordpress as a framework
Wordpress as a framework
 

More from Mithilesh Singh

More from Mithilesh Singh (20)

Data Migration.pdf
Data Migration.pdfData Migration.pdf
Data Migration.pdf
 
SDLC Models.pdf
SDLC Models.pdfSDLC Models.pdf
SDLC Models.pdf
 
Test_Case_Design_Techniques
Test_Case_Design_TechniquesTest_Case_Design_Techniques
Test_Case_Design_Techniques
 
Performance Testing
Performance TestingPerformance Testing
Performance Testing
 
Software_requirement_collection
Software_requirement_collectionSoftware_requirement_collection
Software_requirement_collection
 
Stub_&_Drive
Stub_&_DriveStub_&_Drive
Stub_&_Drive
 
Functional_Testing_Part-1
Functional_Testing_Part-1Functional_Testing_Part-1
Functional_Testing_Part-1
 
TestersMindSet 2022
TestersMindSet 2022TestersMindSet 2022
TestersMindSet 2022
 
API_Testing_with_Postman
API_Testing_with_PostmanAPI_Testing_with_Postman
API_Testing_with_Postman
 
Agile_basics
Agile_basicsAgile_basics
Agile_basics
 
Selenium_Grid
Selenium_GridSelenium_Grid
Selenium_Grid
 
Appium_set_up
Appium_set_upAppium_set_up
Appium_set_up
 
Appium- part 1
Appium- part 1Appium- part 1
Appium- part 1
 
Alpha & Beta Testing
Alpha & Beta TestingAlpha & Beta Testing
Alpha & Beta Testing
 
Severity and Priority
Severity and PrioritySeverity and Priority
Severity and Priority
 
GIT_Overview.
GIT_Overview.GIT_Overview.
GIT_Overview.
 
Selenium-Locators
Selenium-LocatorsSelenium-Locators
Selenium-Locators
 
Browser_Stack_Intro
Browser_Stack_IntroBrowser_Stack_Intro
Browser_Stack_Intro
 
UI_UX_testing tips
UI_UX_testing tipsUI_UX_testing tips
UI_UX_testing tips
 
Emulator vs Simulator
Emulator vs SimulatorEmulator vs Simulator
Emulator vs Simulator
 

Recently uploaded

Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
panagenda
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
FIDO Alliance
 

Recently uploaded (20)

Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptx
 
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
 
Top 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development CompaniesTop 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development Companies
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
Vector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxVector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptx
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
 
الأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهلهالأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهله
 
2024 May Patch Tuesday
2024 May Patch Tuesday2024 May Patch Tuesday
2024 May Patch Tuesday
 
Event-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingEvent-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream Processing
 
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
 
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties ReimaginedEasier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
 
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptxCyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
 
Intro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxIntro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptx
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and Insight
 
Introduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxIntroduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptx
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps Productivity
 
Overview of Hyperledger Foundation
Overview of Hyperledger FoundationOverview of Hyperledger Foundation
Overview of Hyperledger Foundation
 

Cucumber Basics.pdf

  • 3. Behavioral Driven Development (BDD) is a software development approach. It differs by being written in a shared language, which improves communication between tech and non-tech teams and stakeholders. BDD
  • 4. Why we use BDD • Let’s assume there is a requirement from a client for an E Commerce website to increase the sales of the product with implementing some new features on the website, the only challenge of the development team is to convert the client idea in to something that actually delivers the benefits to client, The origin idea is awesome but the only challenge here is that the person who is developing the idea is not the same person is not the same person who has that idea. If the person who has the idea happens to be a talented software developer. Then we might be in luck the idea could be turned into working software without even needing to be explained to anyone else. Now the idea needs to be communicated and has to travel from the business owner(client) to the development team. Note: Cucumber helps to improve communication between technicalandnon-technicalmembersin the same project
  • 5. Gherkin Keywords * Feature. * Scenario. * Given. *When. *Then. *And. * Background
  • 6. * Feature : Each Gherkinfile beginswith a Feature keyword. Feature defines the logicaltest functionality you willtest in this feature file * Background : Backgroundkeywordis used to define steps that are common to allthe tests in the feature file. * Given : It is nothingbut precondition *When : keyworddefinesthe test actionthat will be executed. *Then : verificationofthe output with expected result * And : keywordis used to add conditionsto your steps. * But : Use to give negative type comments.
  • 7. Difference between testNg explanation andCucumber explanation of a scenario TestNg : @Test Public void testAdminUserCanUpdateUserAccPswd(){ // Create Users User userAdmin = new User(UserRole.ADMIN, userName, Password); Use admin user to update another user password String message = userAdmin.updatePassword(user,user_new_password); //Verify password changed Assert.assertEquals(message,”password changed successfully”); Assert. assertEquals(user.getPassword(), user_new_password); } Cucumber: Feature : Update password Scenario : Admin user can update the user password Given : I am in the HR system with an admin account When : I have updated passwordof the another user Then : I receive a messagefor updating passwordsuccessfully And : User’s password is updated to the new password.
  • 8. Options available in cucumber: dryRun : true : checks if all the feature file steps have created step false: default condition Features : set: the path of the feature file. glue : set: the path of step definition file tags : instruct: what tags in the feature file should be executed. monochrome : true: display the console output in much readable way format : set: different report format which we can use. E.g. html, json. A. “Pretty” --print the gherkin source with additional colors format={“pretty”}. B. HTML : this will help to generate HTMLreports at the location mentioned in the formatter itself. format = {“html:Folder_Name”}. C. Json : this report contains all the information from the gherkin source in json format={“json:Folder_Name/cucumber.json”}.
  • 9. Notes • 1.Cucumber options we always keep under the @CucumberOptions annotation under the test runner class inside our framework. E.g. @CucumberOptions( features = "src/test/resources/features", glue = "com/demo/qa/ui/steps", tags = "not @ignore" dryRun= true)
  • 10. Components of the Cucumber framework: 1. Feature file Scenariooutline : verify updating user passwordfeature. Given : I am in the HR system with “<account_type>”account And : There is another user with “<old_password>” password When : I Update password of the user to “<new_password>” Then : I got the message“<message>” And : the user password should be “<final_password>” 2. Step definitionfile: It is a smallpieceof code with a pattern attached to it. Or It is a java method in a classwith an annotation above it. Note: Cucumber findsthe step definitionfilewith the help of glue code in cucumber option. 3. RunnerClass:To execute the case we need cucumber test runner class.
  • 11. Data Driven Approach in Cucumber Framework: A. parameterization without an example keyword. Scenario: Gmail login Test scenario • Given User is already in login page • WhenTitle of login page is Gmail • Then user enters “ABC”and “test@123” • Then user clicks on login button • Then user is on home page Note: we can not test for different no of test inputs in this approach.To overcome this we have to go with the approach 2
  • 12. B. parameterization with example keyword https://www.facebook.com/Testers-Zone-107916170837875/