SlideShare uma empresa Scribd logo
1 de 55
Behavior Driven Development
with SpecFlow and Selenium
Liraz Shay
liraz.shay@yahoo.com
About me
● Test automation expert
● Extensive experience in BDD and SpecFlow
● QA and Automation leader at BurlingtonEnglish
● Blogger (SeleniumPro.net)
Goals
Learn about BDD and Specification-By-Example
Learn all (almost...) about SpecFlow
New perspective for SpecFlow users
BDD / Cucumber best practices
Terminology
❖ Specification-By-Example
❖ Acceptance Test Driven Development (ATDD)
❖ Behaviour Driven Development (BDD)
Presentation Topics
❏ Quick intro/refresh on Specification-By-Example
❏ Introduction to Gherkin
❏ SpecFlow main features
❏ Code examples
❏ SpecFlow and BDD best practices
❏ Short brief about our Selenium-based automation framework
❏ Time for questions
Specification-By-Example
A single source of truth of
software behaviour.
For both non-technical and
technical project members.
The people in charge of defining the requirements (business
analysts) sit down with programmers and testers and discuss a
feature to be implemented. (These roles are often called the three
amigos).
The three amigos come up with examples of how the software
should behave,
At the end, they write them down as Cucumber Scenarios.
Specification Workshops (Three Amigos)
Feature vs Scenario
Outside-In Development (Programmers)
Programmers run those Cucumber Scenarios with
Cucumber, which tells them what needs to be implemented -
what’s missing.
They code a little bit, run Cucumber again and continue until
the feature works as described.
BDD Cycle
Gherkin
.feature files
Gherkin is plain-text English with a
little extra structure.
Gherkin is designed to be easy to
learn by non-programmers
But structured enough to allow
concise description of examples to
illustrate business rules in most
real-world domains
➢ Feature
➢ Scenario
➢ Given, When, Then, And, But (Steps)
➢ Background
➢ Scenario Outline
➢ Examples.
Given
Given steps are used to describe the initial context of
the system ---the scene of the scenario.
It is typically something that happened in the past.
It's ok to have several Given steps (just use And or
But)
When
When steps are used to describe an event, or an
action.
This can be a person interacting with the system, or
it can be an event triggered by another system.
It's strongly recommended you only have a single
When step per scenario.
Background
Instead of repeating the same Given steps in all of the scenarios,
You can literally move such Given steps to the background by
grouping them under a Background section before the first
scenario:
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.
Instead of:
Much easier to read...
Show me the code !!!!!
Purpose of examples
❖ Shared understanding of the acceptance criteria
❖ Documentation: system details
❖ Regression-tests
Test automation becomes expensive, when..
❖ Trying to automate manual tests
❖ Making tests unreadable when automating them
❖ Automating only after completing implementation
Best Practices
Write declarative features
Scenarios should be written like a user would
describe them (as specification, not as test script.)
Beware of scenarios that only describe clicking links
and filling in form fields, or of steps that contain code
or CSS selectors.
Specifications, not scripts:
less workflow based
scenarios
more specifications about
what is needed,
as these are easier to
understand, more precise
and testable;
Abstract:
the specification
should be abstract
enough to highlight
the detail,
remove the noise,
and not being tied to
the implementation of
the user interface;
Push HOW down see:
http://www.marcusoft.net/2013/04/PushTheHowDown.html
When all you really
wanted to say was:
Push HOW down see:
http://www.marcusoft.net/2013/04/PushTheHowDown.html
it's pretty easy to
automate with a few
generic step
definitions
Push HOW down see:
http://www.marcusoft.net/2013/04/PushTheHowDown.html
The first version sucks because:
● it's almost impossible to see the
"tree for the forest". What is
this scenario describing?
● It's boring for any non-technical
person to read
● It was meant to clarify but it just
added confusion
Push HOW down see:
http://www.marcusoft.net/2013/04/PushTheHowDown.html
The second version is better
because:
● it clearly shows the (in this case
very simple) behavior.
● It's understandable by everyone,
even non-techies, even techies.
where did the HOW go then?
Push HOW down see:
http://www.marcusoft.net/2013/04/PushTheHowDown.html
Should we keep the HOW here ?
Well - no... keep pushing
Try to keep your step definition
as simple as possible, preferable
one-liners.
These one-liners can interact
with a DSL or Driver object that
you use to interact with your
system. (Page Objects)
Use page-objects
Page objects are just a design
pattern to ensure automated UI
tests use reusable, modular code.
Not using them, eg, writing
WebDriver code directly in step
definitions, means any changes to
your UI will require updates in
lots of different places instead of
the one ‘page’ class.
Think twice when writing the "As a ... I want to .. so I can ..."
Parts of a user story (Specification by Example, page 72)
• As a stakeholder
• In order to achieve something valuable
• I want some system function
For example,
“As a marketing manager,
so that I can market products directly to customers,
I want the system to request and record personal information when customers register
for a loyalty program.”
Stop once you've an expectation
● No more user actions (click_link and friends) after a Then
● Only assert on Then steps
● Split complicated workflows in different scenarios (i.e.
registration + confirmation + profile completion)
Anti Patterns
Scenario Outlines
Step params (Given a user named "John Doe")
Tables
Bad name on a scenario
A good name on a scenario tell the reader what this
is about. No name leaves the reader guessing.
Scenario: Sign up, login, go to balance screen, check balance, logout
Scenario: Check balance
Lots of user interface details
One problem with this is understanding the purpose.
Another problem is that user interfaces changes a lot
more frequently than the underlying domain logic.
No clear separation between Given/When/Then
What is the difference then?
Given is the context - the past
When is an action that changes the system - the
present
Then is the expected outcome - the near future
SpecFlow Report see:
https://github.com/techtalk/SpecFlow/wiki/Reporting
ReportUnit see: http://relevantcodes.com/reportunit/
Pickles Living Documentation see: http://www.picklesdoc.com
Selenium Framework
Driver.AreYouOn<LoginPage>() : bool
Under the hood:
Create new instance of the login page with short timeout,
If exception was thrown - return false, else true
Selenium Framework
Driver.GoTo<LoginPage>() : LoginPage
Under the hood:
Take the url of the page from the attribute, and navigate to that
page, then return new instance of the login page
Selenium Framework
Page Verifier Attribute
Under the hood:
When creating a new instance of login page, The constructor of
the base class finds the elements with PageVerifierAttribute and
verifies / wait until they are displayed
Selenium Framework
PageComponent vs PageObject
Selenium Framework
Html Elements
Implement classes for common
elements with relevant methods,
TextField - ClearAndType(text)
DropDownList - Select(value/text)
RadioButton -
Check/Uncheck/IsChecked,
etc.
Selenium Framework
WebDriver Wrapper + WebElement Wrapper
Architecture to achieve 100% Stable tests, no unwanted exceptions
For each method on IWebElement:
1) If element is StaleElementReference - Find it again
2) If any exception was thrown while executing the method (click(),Text,etc.) - try again
until 20 sec - if this didn't help - throw the exception
Open source implementation will be available soon in my GitHub
Project name StableSelenium
Other platforms
Cucumber supports over a dozen different software platforms: See: https://cucumber.io/docs
Books
Useful links
http://www.specflow.org/resources/
https://www.youtube.com/playlist?list=PL6tu16kXT9Pp3wrsaYyNRnK1QkvVv6qdI
http://www.testingexcellence.com/bdd-guidelines-best-practices/
http://www.thinkcode.se/blog/2016/06/22/cucumber-antipatterns
Any questions ?
BDD with SpecFlow and Selenium
BDD with SpecFlow and Selenium

Mais conteúdo relacionado

Mais procurados

Katalon Studio - GUI Overview
Katalon Studio - GUI OverviewKatalon Studio - GUI Overview
Katalon Studio - GUI OverviewKatalon Studio
 
What Is Cucumber?
What Is Cucumber?What Is Cucumber?
What Is Cucumber?QATestLab
 
Behavior-Driven Development and Automation Testing Using Cucumber Framework W...
Behavior-Driven Development and Automation Testing Using Cucumber Framework W...Behavior-Driven Development and Automation Testing Using Cucumber Framework W...
Behavior-Driven Development and Automation Testing Using Cucumber Framework W...KMS Technology
 
Introduction to Test Automation
Introduction to Test AutomationIntroduction to Test Automation
Introduction to Test AutomationPekka Klärck
 
Web automation using selenium.ppt
Web automation using selenium.pptWeb automation using selenium.ppt
Web automation using selenium.pptAna Sarbescu
 
katalon studio 툴을 이용한 GUI 테스트 자동화 가이드
katalon studio 툴을 이용한 GUI 테스트 자동화 가이드katalon studio 툴을 이용한 GUI 테스트 자동화 가이드
katalon studio 툴을 이용한 GUI 테스트 자동화 가이드SangIn Choung
 
Cucumber presentation
Cucumber presentationCucumber presentation
Cucumber presentationAkhila B
 
Automation test framework with cucumber – BDD
Automation test framework with cucumber – BDDAutomation test framework with cucumber – BDD
Automation test framework with cucumber – BDD123abcda
 
ATDD Using Robot Framework
ATDD Using Robot FrameworkATDD Using Robot Framework
ATDD Using Robot FrameworkPekka Klärck
 
Functional Tests Automation with Robot Framework
Functional Tests Automation with Robot FrameworkFunctional Tests Automation with Robot Framework
Functional Tests Automation with Robot Frameworklaurent bristiel
 
Test Automation Framework Designs
Test Automation Framework DesignsTest Automation Framework Designs
Test Automation Framework DesignsSauce Labs
 
Automated Testing vs Manual Testing
Automated Testing vs Manual TestingAutomated Testing vs Manual Testing
Automated Testing vs Manual TestingDirecti Group
 
Test Automation Strategies For Agile
Test Automation Strategies For AgileTest Automation Strategies For Agile
Test Automation Strategies For AgileNaresh Jain
 
테스트자동화 성공전략
테스트자동화 성공전략테스트자동화 성공전략
테스트자동화 성공전략SangIn Choung
 

Mais procurados (20)

Katalon Studio - GUI Overview
Katalon Studio - GUI OverviewKatalon Studio - GUI Overview
Katalon Studio - GUI Overview
 
Cucumber presenation
Cucumber presenationCucumber presenation
Cucumber presenation
 
What Is Cucumber?
What Is Cucumber?What Is Cucumber?
What Is Cucumber?
 
BDD with Cucumber
BDD with CucumberBDD with Cucumber
BDD with Cucumber
 
Behavior-Driven Development and Automation Testing Using Cucumber Framework W...
Behavior-Driven Development and Automation Testing Using Cucumber Framework W...Behavior-Driven Development and Automation Testing Using Cucumber Framework W...
Behavior-Driven Development and Automation Testing Using Cucumber Framework W...
 
Introduction to Test Automation
Introduction to Test AutomationIntroduction to Test Automation
Introduction to Test Automation
 
Web automation using selenium.ppt
Web automation using selenium.pptWeb automation using selenium.ppt
Web automation using selenium.ppt
 
Gherkin /BDD intro
Gherkin /BDD introGherkin /BDD intro
Gherkin /BDD intro
 
katalon studio 툴을 이용한 GUI 테스트 자동화 가이드
katalon studio 툴을 이용한 GUI 테스트 자동화 가이드katalon studio 툴을 이용한 GUI 테스트 자동화 가이드
katalon studio 툴을 이용한 GUI 테스트 자동화 가이드
 
Cucumber BDD
Cucumber BDDCucumber BDD
Cucumber BDD
 
Cucumber presentation
Cucumber presentationCucumber presentation
Cucumber presentation
 
Automation test framework with cucumber – BDD
Automation test framework with cucumber – BDDAutomation test framework with cucumber – BDD
Automation test framework with cucumber – BDD
 
ATDD Using Robot Framework
ATDD Using Robot FrameworkATDD Using Robot Framework
ATDD Using Robot Framework
 
BDD: The unit test of the product owner
BDD: The unit test of the product ownerBDD: The unit test of the product owner
BDD: The unit test of the product owner
 
Functional Tests Automation with Robot Framework
Functional Tests Automation with Robot FrameworkFunctional Tests Automation with Robot Framework
Functional Tests Automation with Robot Framework
 
Test Automation Framework Designs
Test Automation Framework DesignsTest Automation Framework Designs
Test Automation Framework Designs
 
BDD in Action - building software that matters
BDD in Action - building software that mattersBDD in Action - building software that matters
BDD in Action - building software that matters
 
Automated Testing vs Manual Testing
Automated Testing vs Manual TestingAutomated Testing vs Manual Testing
Automated Testing vs Manual Testing
 
Test Automation Strategies For Agile
Test Automation Strategies For AgileTest Automation Strategies For Agile
Test Automation Strategies For Agile
 
테스트자동화 성공전략
테스트자동화 성공전략테스트자동화 성공전략
테스트자동화 성공전략
 

Semelhante a BDD with SpecFlow and Selenium

Lessons Learned in a Continuously Developing Service-Oriented Architecture
Lessons Learned in a Continuously Developing Service-Oriented ArchitectureLessons Learned in a Continuously Developing Service-Oriented Architecture
Lessons Learned in a Continuously Developing Service-Oriented Architecturemdwheele
 
BDD approach with Selenium RC
BDD approach with Selenium RCBDD approach with Selenium RC
BDD approach with Selenium RCMykola Kolisnyk
 
Code Review
Code ReviewCode Review
Code ReviewRavi Raj
 
PHPConf.asia 2016 - BDD with Behat for Beginners
PHPConf.asia 2016 - BDD with Behat for BeginnersPHPConf.asia 2016 - BDD with Behat for Beginners
PHPConf.asia 2016 - BDD with Behat for BeginnersAdam Englander
 
How to ace your .NET technical interview :: .Net Technical Check Tuneup
How to ace your .NET technical interview :: .Net Technical Check TuneupHow to ace your .NET technical interview :: .Net Technical Check Tuneup
How to ace your .NET technical interview :: .Net Technical Check TuneupBala Subra
 
Immutable Data and TypeScript in an Ember.js Application
Immutable Data and TypeScript in an Ember.js ApplicationImmutable Data and TypeScript in an Ember.js Application
Immutable Data and TypeScript in an Ember.js ApplicationBill Heaton
 
Front-End Modernization for Mortals
Front-End Modernization for MortalsFront-End Modernization for Mortals
Front-End Modernization for Mortalscgack
 
Front end-modernization
Front end-modernizationFront end-modernization
Front end-modernizationdevObjective
 
A report on mvc using the information
A report on mvc using the informationA report on mvc using the information
A report on mvc using the informationToushik Paul
 
Mastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium SuccessfullyMastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium SuccessfullySpringPeople
 
Viktor Turskyi "Effective NodeJS Application Development"
Viktor Turskyi "Effective NodeJS Application Development"Viktor Turskyi "Effective NodeJS Application Development"
Viktor Turskyi "Effective NodeJS Application Development"Fwdays
 
Zend con 2016 bdd with behat for beginners
Zend con 2016   bdd with behat for beginnersZend con 2016   bdd with behat for beginners
Zend con 2016 bdd with behat for beginnersAdam Englander
 
So You Just Inherited a $Legacy Application… NomadPHP July 2016
So You Just Inherited a $Legacy Application… NomadPHP July 2016So You Just Inherited a $Legacy Application… NomadPHP July 2016
So You Just Inherited a $Legacy Application… NomadPHP July 2016Joe Ferguson
 
Testing Experience - Evolution of Test Automation Frameworks
Testing Experience - Evolution of Test Automation FrameworksTesting Experience - Evolution of Test Automation Frameworks
Testing Experience - Evolution of Test Automation FrameworksŁukasz Morawski
 
So You Just Inherited a $Legacy Application...
So You Just Inherited a $Legacy Application...So You Just Inherited a $Legacy Application...
So You Just Inherited a $Legacy Application...Joe Ferguson
 
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...Paul Jensen
 

Semelhante a BDD with SpecFlow and Selenium (20)

Lessons Learned in a Continuously Developing Service-Oriented Architecture
Lessons Learned in a Continuously Developing Service-Oriented ArchitectureLessons Learned in a Continuously Developing Service-Oriented Architecture
Lessons Learned in a Continuously Developing Service-Oriented Architecture
 
BDD approach with Selenium RC
BDD approach with Selenium RCBDD approach with Selenium RC
BDD approach with Selenium RC
 
Code Review
Code ReviewCode Review
Code Review
 
Reusable Apps
Reusable AppsReusable Apps
Reusable Apps
 
PHPConf.asia 2016 - BDD with Behat for Beginners
PHPConf.asia 2016 - BDD with Behat for BeginnersPHPConf.asia 2016 - BDD with Behat for Beginners
PHPConf.asia 2016 - BDD with Behat for Beginners
 
How to ace your .NET technical interview :: .Net Technical Check Tuneup
How to ace your .NET technical interview :: .Net Technical Check TuneupHow to ace your .NET technical interview :: .Net Technical Check Tuneup
How to ace your .NET technical interview :: .Net Technical Check Tuneup
 
DDD with Behat
DDD with BehatDDD with Behat
DDD with Behat
 
Immutable Data and TypeScript in an Ember.js Application
Immutable Data and TypeScript in an Ember.js ApplicationImmutable Data and TypeScript in an Ember.js Application
Immutable Data and TypeScript in an Ember.js Application
 
Front-End Modernization for Mortals
Front-End Modernization for MortalsFront-End Modernization for Mortals
Front-End Modernization for Mortals
 
Front end-modernization
Front end-modernizationFront end-modernization
Front end-modernization
 
Front end-modernization
Front end-modernizationFront end-modernization
Front end-modernization
 
A report on mvc using the information
A report on mvc using the informationA report on mvc using the information
A report on mvc using the information
 
Drupal 7 ci and testing
Drupal 7 ci and testingDrupal 7 ci and testing
Drupal 7 ci and testing
 
Mastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium SuccessfullyMastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium Successfully
 
Viktor Turskyi "Effective NodeJS Application Development"
Viktor Turskyi "Effective NodeJS Application Development"Viktor Turskyi "Effective NodeJS Application Development"
Viktor Turskyi "Effective NodeJS Application Development"
 
Zend con 2016 bdd with behat for beginners
Zend con 2016   bdd with behat for beginnersZend con 2016   bdd with behat for beginners
Zend con 2016 bdd with behat for beginners
 
So You Just Inherited a $Legacy Application… NomadPHP July 2016
So You Just Inherited a $Legacy Application… NomadPHP July 2016So You Just Inherited a $Legacy Application… NomadPHP July 2016
So You Just Inherited a $Legacy Application… NomadPHP July 2016
 
Testing Experience - Evolution of Test Automation Frameworks
Testing Experience - Evolution of Test Automation FrameworksTesting Experience - Evolution of Test Automation Frameworks
Testing Experience - Evolution of Test Automation Frameworks
 
So You Just Inherited a $Legacy Application...
So You Just Inherited a $Legacy Application...So You Just Inherited a $Legacy Application...
So You Just Inherited a $Legacy Application...
 
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
 

Último

Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
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
 
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
 
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
 
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
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
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
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
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
 
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
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
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
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
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
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
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
 
(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
 

Último (20)

Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
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
 
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...
 
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
 
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
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
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
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
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
 
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
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
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
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
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
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
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 ...
 
(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...
 

BDD with SpecFlow and Selenium

  • 1. Behavior Driven Development with SpecFlow and Selenium Liraz Shay liraz.shay@yahoo.com
  • 2. About me ● Test automation expert ● Extensive experience in BDD and SpecFlow ● QA and Automation leader at BurlingtonEnglish ● Blogger (SeleniumPro.net)
  • 3. Goals Learn about BDD and Specification-By-Example Learn all (almost...) about SpecFlow New perspective for SpecFlow users BDD / Cucumber best practices
  • 4. Terminology ❖ Specification-By-Example ❖ Acceptance Test Driven Development (ATDD) ❖ Behaviour Driven Development (BDD)
  • 5. Presentation Topics ❏ Quick intro/refresh on Specification-By-Example ❏ Introduction to Gherkin ❏ SpecFlow main features ❏ Code examples ❏ SpecFlow and BDD best practices ❏ Short brief about our Selenium-based automation framework ❏ Time for questions
  • 6. Specification-By-Example A single source of truth of software behaviour. For both non-technical and technical project members.
  • 7. The people in charge of defining the requirements (business analysts) sit down with programmers and testers and discuss a feature to be implemented. (These roles are often called the three amigos). The three amigos come up with examples of how the software should behave, At the end, they write them down as Cucumber Scenarios. Specification Workshops (Three Amigos)
  • 8.
  • 9.
  • 10.
  • 12.
  • 13. Outside-In Development (Programmers) Programmers run those Cucumber Scenarios with Cucumber, which tells them what needs to be implemented - what’s missing. They code a little bit, run Cucumber again and continue until the feature works as described.
  • 15. Gherkin .feature files Gherkin is plain-text English with a little extra structure. Gherkin is designed to be easy to learn by non-programmers But structured enough to allow concise description of examples to illustrate business rules in most real-world domains ➢ Feature ➢ Scenario ➢ Given, When, Then, And, But (Steps) ➢ Background ➢ Scenario Outline ➢ Examples.
  • 16. Given Given steps are used to describe the initial context of the system ---the scene of the scenario. It is typically something that happened in the past. It's ok to have several Given steps (just use And or But)
  • 17. When When steps are used to describe an event, or an action. This can be a person interacting with the system, or it can be an event triggered by another system. It's strongly recommended you only have a single When step per scenario.
  • 18. Background Instead of repeating the same Given steps in all of the scenarios, You can literally move such Given steps to the background by grouping them under a Background section before the first scenario:
  • 19. 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.
  • 21. Much easier to read...
  • 22. Show me the code !!!!!
  • 23. Purpose of examples ❖ Shared understanding of the acceptance criteria ❖ Documentation: system details ❖ Regression-tests
  • 24. Test automation becomes expensive, when.. ❖ Trying to automate manual tests ❖ Making tests unreadable when automating them ❖ Automating only after completing implementation
  • 26. Write declarative features Scenarios should be written like a user would describe them (as specification, not as test script.) Beware of scenarios that only describe clicking links and filling in form fields, or of steps that contain code or CSS selectors.
  • 27. Specifications, not scripts: less workflow based scenarios more specifications about what is needed, as these are easier to understand, more precise and testable;
  • 28. Abstract: the specification should be abstract enough to highlight the detail, remove the noise, and not being tied to the implementation of the user interface;
  • 29. Push HOW down see: http://www.marcusoft.net/2013/04/PushTheHowDown.html When all you really wanted to say was:
  • 30. Push HOW down see: http://www.marcusoft.net/2013/04/PushTheHowDown.html it's pretty easy to automate with a few generic step definitions
  • 31. Push HOW down see: http://www.marcusoft.net/2013/04/PushTheHowDown.html The first version sucks because: ● it's almost impossible to see the "tree for the forest". What is this scenario describing? ● It's boring for any non-technical person to read ● It was meant to clarify but it just added confusion
  • 32. Push HOW down see: http://www.marcusoft.net/2013/04/PushTheHowDown.html The second version is better because: ● it clearly shows the (in this case very simple) behavior. ● It's understandable by everyone, even non-techies, even techies. where did the HOW go then?
  • 33. Push HOW down see: http://www.marcusoft.net/2013/04/PushTheHowDown.html Should we keep the HOW here ? Well - no... keep pushing Try to keep your step definition as simple as possible, preferable one-liners. These one-liners can interact with a DSL or Driver object that you use to interact with your system. (Page Objects)
  • 34. Use page-objects Page objects are just a design pattern to ensure automated UI tests use reusable, modular code. Not using them, eg, writing WebDriver code directly in step definitions, means any changes to your UI will require updates in lots of different places instead of the one ‘page’ class.
  • 35. Think twice when writing the "As a ... I want to .. so I can ..." Parts of a user story (Specification by Example, page 72) • As a stakeholder • In order to achieve something valuable • I want some system function For example, “As a marketing manager, so that I can market products directly to customers, I want the system to request and record personal information when customers register for a loyalty program.”
  • 36. Stop once you've an expectation ● No more user actions (click_link and friends) after a Then ● Only assert on Then steps ● Split complicated workflows in different scenarios (i.e. registration + confirmation + profile completion)
  • 37. Anti Patterns Scenario Outlines Step params (Given a user named "John Doe") Tables
  • 38. Bad name on a scenario A good name on a scenario tell the reader what this is about. No name leaves the reader guessing. Scenario: Sign up, login, go to balance screen, check balance, logout Scenario: Check balance
  • 39. Lots of user interface details One problem with this is understanding the purpose. Another problem is that user interfaces changes a lot more frequently than the underlying domain logic.
  • 40. No clear separation between Given/When/Then What is the difference then? Given is the context - the past When is an action that changes the system - the present Then is the expected outcome - the near future
  • 43. Pickles Living Documentation see: http://www.picklesdoc.com
  • 44. Selenium Framework Driver.AreYouOn<LoginPage>() : bool Under the hood: Create new instance of the login page with short timeout, If exception was thrown - return false, else true
  • 45. Selenium Framework Driver.GoTo<LoginPage>() : LoginPage Under the hood: Take the url of the page from the attribute, and navigate to that page, then return new instance of the login page
  • 46. Selenium Framework Page Verifier Attribute Under the hood: When creating a new instance of login page, The constructor of the base class finds the elements with PageVerifierAttribute and verifies / wait until they are displayed
  • 48. Selenium Framework Html Elements Implement classes for common elements with relevant methods, TextField - ClearAndType(text) DropDownList - Select(value/text) RadioButton - Check/Uncheck/IsChecked, etc.
  • 49. Selenium Framework WebDriver Wrapper + WebElement Wrapper Architecture to achieve 100% Stable tests, no unwanted exceptions For each method on IWebElement: 1) If element is StaleElementReference - Find it again 2) If any exception was thrown while executing the method (click(),Text,etc.) - try again until 20 sec - if this didn't help - throw the exception Open source implementation will be available soon in my GitHub Project name StableSelenium
  • 50. Other platforms Cucumber supports over a dozen different software platforms: See: https://cucumber.io/docs
  • 51. Books