SlideShare a Scribd company logo
1 of 17
for
Automated Acceptance Testing
What is Acceptance Testing ?
● We call them acceptance tests because they express what the software
needs to do in order for the stakeholder to find it acceptable.
● These tests are different from unit tests, which are aimed at developers and
help them to drive out and check their software designs.
● Acceptance tests more aligned with requirements specification which is
derived from the stakeholder’s requirements
“Unit tests ensure you build the thing right, while Acceptance tests ensure you
build the right thing”
How Cucumber Works
Your Project
Features
Scenarios
Steps
Step Definitions
Support Code
Automation Library
Your System
Business facing
Technology
facing
Gherkin
Gherkin is the language that Cucumber
understands.
It is a Business Readable, Domain Specific
Language that lets you describe behaviour of the
software without detailing how that behaviour is
implemented.
● It's a line-oriented language that uses
indentation to define structure.
● Line endings terminate statements (eg,
steps).
● Either spaces or tabs may be used for
indentation
● Most lines start with a keyword.
● Comment lines are allowed anywhere in
the file and begin with a hash sign (#)
and some amount of text.
● The parser divides the input into
features, scenarios and steps.
● When you run the feature the trailing
portion (after the keyword) of each step
is matched to a code block called Step
Definitions.
Fundamentals in Gherkin syntax
Feature
● A .feature file is supposed to describe a single feature of the system.
● It's just a way to provide a high-level description of a software feature, and to group
related scenarios.
Feature: Account Holder withdraws cash
Scenario: Account has sufficient funds
Given the account balance is $100
And the card is valid
And the machine contains enough money
When the Account Holder requests $20
Then the ATM should dispense $20
And the account balance should be $80
And the card should be returned
Cont.
Scenario
● To actually express the behavior we want, each feature contains several scenarios.
● Each scenario is a single concrete example of how the system should behave in a
particular situation.
● If you add together the behavior defined by all of the scenarios, that’s the expected
behavior of the feature itself
Steps
● A step typically starts with Given, When or Then. If there are multiple Given or When
steps underneath each other, you can use And or But.
● Cucumber does not differentiate between the keywords, but choosing the right one is
important for the readability of the scenario as a whole.
Cont.
Given to set up the context where the scenario happens,
When to interact with the system (i.e. Calling the API)
Then to check that the outcome of that interaction was what we expect
And, But
We can add more steps to each Given, When, or Then section of the scenario using the
keywords And and But:
Scenario: Attempt withdrawal using stolen card
Given I have $100 in my account
But my card is invalid
When I request $50
Then my card should not be returned
And I should be told to contact the bank
Organizing tests
Background
● A background section in a feature file allows you to specify a set of steps that are
common to every scenario in the file.
● Instead of having to repeat those steps over and over for each scenario, just move them
into a Background element.
Advantages:
● If you ever need to change those steps, you have to change them in only
one place.
● The importance of those steps fades into the background so that when
you’re reading each individual scenario, you can focus on what is unique
and important about that scenario.
Cont.
Background Example:
Cont.
Scenario Outline
● When you have a complex business rule with several variable inputs or outputs you
might end up creating several scenarios that only differ by their values.
● A Scenario Outline section is always followed by one or more Examples sections, which
are a container for a table.
● The table must have a header row corresponding to the variables in the Scenario Outline
steps.
● Each of the rows below will create a new Scenario, filling in the variable values.
Cont.
Scenario Outline Example:
Cont.
Tags
● Tag is a way to group Scenarios.
● They are @ prefixed strings and you can place as many tags as you like above Feature, Scenario,
Scenario Outline or Examples keywords.
● Tags are inherited from parent elements. For example, if you place a tag above a Feature, all
scenarios in that feature will get that tag.
● You can tell Cucumber to only run scenarios with certain tags, or to exclude scenarios with certain
tags.
● If you want to skip some tests from executing, then use ~ with tag name.
Cont.
Tags Example:
Step Definitions
● When Cucumber executes a Step in a Scenario it will look for a matching Step Definition to
execute.
● A Step Definition is a small piece of code with a pattern attached to it.
● The pattern is used to link the step definition to all the matching Steps, and the code is what
Cucumber will execute when it sees a Gherkin Step.
● Java example:
● Step definition can be written in any language such as Ruby, Java, Python, C# (using SpecFlow), C++,
PHP (using Behat) etc. because Cucumber supported with almost all the popular languages.
● Installation and configurations will be specific to each language.
For more info: https://cucumber.io/docs
Framework integration
❖ Cucumber is not a Browser Automation tool, but it works well with Browser Automation tools such
as:
➢ Selenium Webdriver
➢ Capybara
➢ Watir
❖ Serenity - an open source reporting library that helps you write better structured, more
maintainable automated acceptance criteria, and also produces rich meaningful test reports.
(http://thucydides.info/docs/articles/an-introduction-to-serenity-bdd-with-cucumber.html)
Serenity not only reports on whether a test passes or fails, but documents what it did, in a step-by-
step narrative format that includes test data and screenshots for web tests.
Example reports
Cucumber for automated acceptance testing.pptx

More Related Content

Similar to Cucumber for automated acceptance testing.pptx

Design Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best PracticesDesign Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best PracticesInductive Automation
 
BDD Selenium for Agile Teams - User Stories
BDD Selenium for Agile Teams - User StoriesBDD Selenium for Agile Teams - User Stories
BDD Selenium for Agile Teams - User StoriesSauce Labs
 
Guidelines to understand durable functions with .net core, c# and stateful se...
Guidelines to understand durable functions with .net core, c# and stateful se...Guidelines to understand durable functions with .net core, c# and stateful se...
Guidelines to understand durable functions with .net core, c# and stateful se...Concetto Labs
 
Taming the Legacy Beast: Turning wild old code into a sleak new thoroughbread.
Taming the Legacy Beast: Turning wild old code into a sleak new thoroughbread.Taming the Legacy Beast: Turning wild old code into a sleak new thoroughbread.
Taming the Legacy Beast: Turning wild old code into a sleak new thoroughbread.Chris Laning
 
PERFORMANCE TESTING USING LOAD RUNNER
PERFORMANCE  TESTING  USING  LOAD RUNNERPERFORMANCE  TESTING  USING  LOAD RUNNER
PERFORMANCE TESTING USING LOAD RUNNERAjithaG9
 
Simplified Troubleshooting through API Scripting
Simplified Troubleshooting through API Scripting Simplified Troubleshooting through API Scripting
Simplified Troubleshooting through API Scripting Network Automation Forum
 
Unit testing (Exploring the other side as a tester)
Unit testing (Exploring the other side as a tester)Unit testing (Exploring the other side as a tester)
Unit testing (Exploring the other side as a tester)Abhijeet Vaikar
 
classVII_Coding_Teacher_Presentation.pptx
classVII_Coding_Teacher_Presentation.pptxclassVII_Coding_Teacher_Presentation.pptx
classVII_Coding_Teacher_Presentation.pptxssusere336f4
 
CQRS and Event Sourcing in Action
CQRS and Event  Sourcing in ActionCQRS and Event  Sourcing in Action
CQRS and Event Sourcing in ActionKnoldus Inc.
 
BDD with SpecFlow and Selenium
BDD with SpecFlow and SeleniumBDD with SpecFlow and Selenium
BDD with SpecFlow and SeleniumLiraz Shay
 
classVI_Coding_Teacher_Presentation.pptx
classVI_Coding_Teacher_Presentation.pptxclassVI_Coding_Teacher_Presentation.pptx
classVI_Coding_Teacher_Presentation.pptxssusere336f4
 
INTRODUCTION TO CODING-CLASS VI LEVEL-DESCRIPTION ABOUT SYNTAX LANGUAGE
INTRODUCTION TO CODING-CLASS VI LEVEL-DESCRIPTION ABOUT SYNTAX LANGUAGEINTRODUCTION TO CODING-CLASS VI LEVEL-DESCRIPTION ABOUT SYNTAX LANGUAGE
INTRODUCTION TO CODING-CLASS VI LEVEL-DESCRIPTION ABOUT SYNTAX LANGUAGERathnaM16
 

Similar to Cucumber for automated acceptance testing.pptx (20)

Design Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best PracticesDesign Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best Practices
 
BDD Selenium for Agile Teams - User Stories
BDD Selenium for Agile Teams - User StoriesBDD Selenium for Agile Teams - User Stories
BDD Selenium for Agile Teams - User Stories
 
Gherkin model BDD
Gherkin model BDDGherkin model BDD
Gherkin model BDD
 
Cucumber & gherkin language
Cucumber & gherkin languageCucumber & gherkin language
Cucumber & gherkin language
 
DAA Unit 1.pdf
DAA Unit 1.pdfDAA Unit 1.pdf
DAA Unit 1.pdf
 
Guidelines to understand durable functions with .net core, c# and stateful se...
Guidelines to understand durable functions with .net core, c# and stateful se...Guidelines to understand durable functions with .net core, c# and stateful se...
Guidelines to understand durable functions with .net core, c# and stateful se...
 
Gherkin model1
Gherkin model1Gherkin model1
Gherkin model1
 
Taming the Legacy Beast: Turning wild old code into a sleak new thoroughbread.
Taming the Legacy Beast: Turning wild old code into a sleak new thoroughbread.Taming the Legacy Beast: Turning wild old code into a sleak new thoroughbread.
Taming the Legacy Beast: Turning wild old code into a sleak new thoroughbread.
 
Survelaine murillo ppt
Survelaine murillo pptSurvelaine murillo ppt
Survelaine murillo ppt
 
Switch case looping
Switch case loopingSwitch case looping
Switch case looping
 
PERFORMANCE TESTING USING LOAD RUNNER
PERFORMANCE  TESTING  USING  LOAD RUNNERPERFORMANCE  TESTING  USING  LOAD RUNNER
PERFORMANCE TESTING USING LOAD RUNNER
 
Simplified Troubleshooting through API Scripting
Simplified Troubleshooting through API Scripting Simplified Troubleshooting through API Scripting
Simplified Troubleshooting through API Scripting
 
Unit testing (Exploring the other side as a tester)
Unit testing (Exploring the other side as a tester)Unit testing (Exploring the other side as a tester)
Unit testing (Exploring the other side as a tester)
 
classVII_Coding_Teacher_Presentation.pptx
classVII_Coding_Teacher_Presentation.pptxclassVII_Coding_Teacher_Presentation.pptx
classVII_Coding_Teacher_Presentation.pptx
 
CQRS and Event Sourcing in Action
CQRS and Event  Sourcing in ActionCQRS and Event  Sourcing in Action
CQRS and Event Sourcing in Action
 
Gherkin /BDD intro
Gherkin /BDD introGherkin /BDD intro
Gherkin /BDD intro
 
BDD with SpecFlow and Selenium
BDD with SpecFlow and SeleniumBDD with SpecFlow and Selenium
BDD with SpecFlow and Selenium
 
classVI_Coding_Teacher_Presentation.pptx
classVI_Coding_Teacher_Presentation.pptxclassVI_Coding_Teacher_Presentation.pptx
classVI_Coding_Teacher_Presentation.pptx
 
INTRODUCTION TO CODING-CLASS VI LEVEL-DESCRIPTION ABOUT SYNTAX LANGUAGE
INTRODUCTION TO CODING-CLASS VI LEVEL-DESCRIPTION ABOUT SYNTAX LANGUAGEINTRODUCTION TO CODING-CLASS VI LEVEL-DESCRIPTION ABOUT SYNTAX LANGUAGE
INTRODUCTION TO CODING-CLASS VI LEVEL-DESCRIPTION ABOUT SYNTAX LANGUAGE
 
Chapter 2- Prog101.ppt
Chapter 2- Prog101.pptChapter 2- Prog101.ppt
Chapter 2- Prog101.ppt
 

More from Kalhan Liyanage

Progressive web app testing
Progressive web app testingProgressive web app testing
Progressive web app testingKalhan Liyanage
 
How to do a Formal presentaion - features and how to design a formal presentaion
How to do a Formal presentaion - features and how to design a formal presentaionHow to do a Formal presentaion - features and how to design a formal presentaion
How to do a Formal presentaion - features and how to design a formal presentaionKalhan Liyanage
 
The iron lady margaret thatcher
The iron lady margaret thatcherThe iron lady margaret thatcher
The iron lady margaret thatcherKalhan Liyanage
 
database recovery techniques
database recovery techniques database recovery techniques
database recovery techniques Kalhan Liyanage
 

More from Kalhan Liyanage (7)

Progressive web app testing
Progressive web app testingProgressive web app testing
Progressive web app testing
 
Stay Young At Heart
Stay Young At HeartStay Young At Heart
Stay Young At Heart
 
Microsoft corporation
Microsoft corporationMicrosoft corporation
Microsoft corporation
 
How to do a Formal presentaion - features and how to design a formal presentaion
How to do a Formal presentaion - features and how to design a formal presentaionHow to do a Formal presentaion - features and how to design a formal presentaion
How to do a Formal presentaion - features and how to design a formal presentaion
 
The iron lady margaret thatcher
The iron lady margaret thatcherThe iron lady margaret thatcher
The iron lady margaret thatcher
 
database recovery techniques
database recovery techniques database recovery techniques
database recovery techniques
 
Nanotechnology
NanotechnologyNanotechnology
Nanotechnology
 

Recently uploaded

SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....ShaimaaMohamedGalal
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfCionsystems
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 

Recently uploaded (20)

SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdf
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 

Cucumber for automated acceptance testing.pptx

  • 2. What is Acceptance Testing ? ● We call them acceptance tests because they express what the software needs to do in order for the stakeholder to find it acceptable. ● These tests are different from unit tests, which are aimed at developers and help them to drive out and check their software designs. ● Acceptance tests more aligned with requirements specification which is derived from the stakeholder’s requirements “Unit tests ensure you build the thing right, while Acceptance tests ensure you build the right thing”
  • 3. How Cucumber Works Your Project Features Scenarios Steps Step Definitions Support Code Automation Library Your System Business facing Technology facing
  • 4. Gherkin Gherkin is the language that Cucumber understands. It is a Business Readable, Domain Specific Language that lets you describe behaviour of the software without detailing how that behaviour is implemented. ● It's a line-oriented language that uses indentation to define structure. ● Line endings terminate statements (eg, steps). ● Either spaces or tabs may be used for indentation ● Most lines start with a keyword. ● Comment lines are allowed anywhere in the file and begin with a hash sign (#) and some amount of text. ● The parser divides the input into features, scenarios and steps. ● When you run the feature the trailing portion (after the keyword) of each step is matched to a code block called Step Definitions.
  • 5. Fundamentals in Gherkin syntax Feature ● A .feature file is supposed to describe a single feature of the system. ● It's just a way to provide a high-level description of a software feature, and to group related scenarios. Feature: Account Holder withdraws cash Scenario: Account has sufficient funds Given the account balance is $100 And the card is valid And the machine contains enough money When the Account Holder requests $20 Then the ATM should dispense $20 And the account balance should be $80 And the card should be returned
  • 6. Cont. Scenario ● To actually express the behavior we want, each feature contains several scenarios. ● Each scenario is a single concrete example of how the system should behave in a particular situation. ● If you add together the behavior defined by all of the scenarios, that’s the expected behavior of the feature itself Steps ● A step typically starts with Given, When or Then. If there are multiple Given or When steps underneath each other, you can use And or But. ● Cucumber does not differentiate between the keywords, but choosing the right one is important for the readability of the scenario as a whole.
  • 7. Cont. Given to set up the context where the scenario happens, When to interact with the system (i.e. Calling the API) Then to check that the outcome of that interaction was what we expect And, But We can add more steps to each Given, When, or Then section of the scenario using the keywords And and But: Scenario: Attempt withdrawal using stolen card Given I have $100 in my account But my card is invalid When I request $50 Then my card should not be returned And I should be told to contact the bank
  • 8. Organizing tests Background ● A background section in a feature file allows you to specify a set of steps that are common to every scenario in the file. ● Instead of having to repeat those steps over and over for each scenario, just move them into a Background element. Advantages: ● If you ever need to change those steps, you have to change them in only one place. ● The importance of those steps fades into the background so that when you’re reading each individual scenario, you can focus on what is unique and important about that scenario.
  • 10. Cont. Scenario Outline ● When you have a complex business rule with several variable inputs or outputs you might end up creating several scenarios that only differ by their values. ● A Scenario Outline section is always followed by one or more Examples sections, which are a container for a table. ● The table must have a header row corresponding to the variables in the Scenario Outline steps. ● Each of the rows below will create a new Scenario, filling in the variable values.
  • 12. Cont. Tags ● Tag is a way to group Scenarios. ● They are @ prefixed strings and you can place as many tags as you like above Feature, Scenario, Scenario Outline or Examples keywords. ● Tags are inherited from parent elements. For example, if you place a tag above a Feature, all scenarios in that feature will get that tag. ● You can tell Cucumber to only run scenarios with certain tags, or to exclude scenarios with certain tags. ● If you want to skip some tests from executing, then use ~ with tag name.
  • 14. Step Definitions ● When Cucumber executes a Step in a Scenario it will look for a matching Step Definition to execute. ● A Step Definition is a small piece of code with a pattern attached to it. ● The pattern is used to link the step definition to all the matching Steps, and the code is what Cucumber will execute when it sees a Gherkin Step. ● Java example: ● Step definition can be written in any language such as Ruby, Java, Python, C# (using SpecFlow), C++, PHP (using Behat) etc. because Cucumber supported with almost all the popular languages. ● Installation and configurations will be specific to each language. For more info: https://cucumber.io/docs
  • 15. Framework integration ❖ Cucumber is not a Browser Automation tool, but it works well with Browser Automation tools such as: ➢ Selenium Webdriver ➢ Capybara ➢ Watir ❖ Serenity - an open source reporting library that helps you write better structured, more maintainable automated acceptance criteria, and also produces rich meaningful test reports. (http://thucydides.info/docs/articles/an-introduction-to-serenity-bdd-with-cucumber.html) Serenity not only reports on whether a test passes or fails, but documents what it did, in a step-by- step narrative format that includes test data and screenshots for web tests.