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

Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
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
 
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
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
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
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
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
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
(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
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
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
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 

Recently uploaded (20)

Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
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
 
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...
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
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
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
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 ...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
(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...
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
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
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 

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.