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

Behavior driven development (bdd)
Behavior driven development (bdd)Behavior driven development (bdd)
Behavior driven development (bdd)Rohit Bisht
 
Test Driven Development With Python
Test Driven Development With PythonTest Driven Development With Python
Test Driven Development With PythonSiddhi
 
Robot Framework Dos And Don'ts
Robot Framework Dos And Don'tsRobot Framework Dos And Don'ts
Robot Framework Dos And Don'tsPekka Klärck
 
Best practices for test automation
Best practices for test automationBest practices for test automation
Best practices for test automationDavid Tzemach
 
Test Automation Framework using Cucumber BDD overview (part 1)
Test Automation Framework using Cucumber BDD overview (part 1)Test Automation Framework using Cucumber BDD overview (part 1)
Test Automation Framework using Cucumber BDD overview (part 1)Mindfire Solutions
 
Selenium with Cucumber
Selenium  with Cucumber Selenium  with Cucumber
Selenium with Cucumber Knoldus Inc.
 
BDD presentation
BDD presentationBDD presentation
BDD presentationtemebele
 
Agile Test Management Using Jira and Zephyr
Agile Test Management Using Jira and ZephyrAgile Test Management Using Jira and Zephyr
Agile Test Management Using Jira and ZephyrXBOSoft
 
Testing in-python-and-pytest-framework
Testing in-python-and-pytest-frameworkTesting in-python-and-pytest-framework
Testing in-python-and-pytest-frameworkArulalan T
 
Cucumber spec - a tool takes your bdd to the next level
Cucumber spec - a tool takes your bdd to the next levelCucumber spec - a tool takes your bdd to the next level
Cucumber spec - a tool takes your bdd to the next levelnextbuild
 
Amazon CodeGuru - Automate Code review and Code performance monitoring
Amazon CodeGuru - Automate Code review and Code performance monitoringAmazon CodeGuru - Automate Code review and Code performance monitoring
Amazon CodeGuru - Automate Code review and Code performance monitoringOlawale Olaleye
 
BDD WITH CUCUMBER AND JAVA
BDD WITH CUCUMBER AND JAVABDD WITH CUCUMBER AND JAVA
BDD WITH CUCUMBER AND JAVASrinivas Katakam
 
Py.test
Py.testPy.test
Py.testsoasme
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven DevelopmentJohn Blum
 
An Introduction to Gradle for Java Developers
An Introduction to Gradle for Java DevelopersAn Introduction to Gradle for Java Developers
An Introduction to Gradle for Java DevelopersKostas Saidis
 
Robot Framework Introduction
Robot Framework IntroductionRobot Framework Introduction
Robot Framework IntroductionPekka Klärck
 

Mais procurados (20)

Behavior driven development (bdd)
Behavior driven development (bdd)Behavior driven development (bdd)
Behavior driven development (bdd)
 
Test Driven Development With Python
Test Driven Development With PythonTest Driven Development With Python
Test Driven Development With Python
 
Cucumber BDD
Cucumber BDDCucumber BDD
Cucumber BDD
 
BDD with Cucumber
BDD with CucumberBDD with Cucumber
BDD with Cucumber
 
Robot Framework Dos And Don'ts
Robot Framework Dos And Don'tsRobot Framework Dos And Don'ts
Robot Framework Dos And Don'ts
 
Test Automation Framework with BDD and Cucumber
Test Automation Framework with BDD and CucumberTest Automation Framework with BDD and Cucumber
Test Automation Framework with BDD and Cucumber
 
Best practices for test automation
Best practices for test automationBest practices for test automation
Best practices for test automation
 
Test Automation Framework using Cucumber BDD overview (part 1)
Test Automation Framework using Cucumber BDD overview (part 1)Test Automation Framework using Cucumber BDD overview (part 1)
Test Automation Framework using Cucumber BDD overview (part 1)
 
Selenium with Cucumber
Selenium  with Cucumber Selenium  with Cucumber
Selenium with Cucumber
 
BDD presentation
BDD presentationBDD presentation
BDD presentation
 
Agile Test Management Using Jira and Zephyr
Agile Test Management Using Jira and ZephyrAgile Test Management Using Jira and Zephyr
Agile Test Management Using Jira and Zephyr
 
Testing in-python-and-pytest-framework
Testing in-python-and-pytest-frameworkTesting in-python-and-pytest-framework
Testing in-python-and-pytest-framework
 
BDD for APIs
BDD for APIsBDD for APIs
BDD for APIs
 
Cucumber spec - a tool takes your bdd to the next level
Cucumber spec - a tool takes your bdd to the next levelCucumber spec - a tool takes your bdd to the next level
Cucumber spec - a tool takes your bdd to the next level
 
Amazon CodeGuru - Automate Code review and Code performance monitoring
Amazon CodeGuru - Automate Code review and Code performance monitoringAmazon CodeGuru - Automate Code review and Code performance monitoring
Amazon CodeGuru - Automate Code review and Code performance monitoring
 
BDD WITH CUCUMBER AND JAVA
BDD WITH CUCUMBER AND JAVABDD WITH CUCUMBER AND JAVA
BDD WITH CUCUMBER AND JAVA
 
Py.test
Py.testPy.test
Py.test
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven Development
 
An Introduction to Gradle for Java Developers
An Introduction to Gradle for Java DevelopersAn Introduction to Gradle for Java Developers
An Introduction to Gradle for Java Developers
 
Robot Framework Introduction
Robot Framework IntroductionRobot Framework Introduction
Robot Framework Introduction
 

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

Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentationvaddepallysandeep122
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
How To Manage Restaurant Staff -BTRESTRO
How To Manage Restaurant Staff -BTRESTROHow To Manage Restaurant Staff -BTRESTRO
How To Manage Restaurant Staff -BTRESTROmotivationalword821
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Rob Geurden
 
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfInnovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfYashikaSharma391629
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 

Último (20)

Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
How To Manage Restaurant Staff -BTRESTRO
How To Manage Restaurant Staff -BTRESTROHow To Manage Restaurant Staff -BTRESTRO
How To Manage Restaurant Staff -BTRESTRO
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...
 
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfInnovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 

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