SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Was ist angesagt?

Automated Testing vs Manual Testing
Automated Testing vs Manual TestingAutomated Testing vs Manual Testing
Automated Testing vs Manual Testingdidev
 
Test Automation and Selenium
Test Automation and SeleniumTest Automation and Selenium
Test Automation and SeleniumKarapet Sarkisyan
 
Introduction to BDD with Cucumber for Java
Introduction to BDD with Cucumber for JavaIntroduction to BDD with Cucumber for Java
Introduction to BDD with Cucumber for JavaSeb Rose
 
BDD WITH CUCUMBER AND JAVA
BDD WITH CUCUMBER AND JAVABDD WITH CUCUMBER AND JAVA
BDD WITH CUCUMBER AND JAVASrinivas Katakam
 
Introduction to Bdd and cucumber
Introduction to Bdd and cucumberIntroduction to Bdd and cucumber
Introduction to Bdd and cucumberNibu Baby
 
Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)Lars Thorup
 
An overview of selenium webdriver
An overview of selenium webdriverAn overview of selenium webdriver
An overview of selenium webdriverAnuraj S.L
 
Introduction to jest
Introduction to jestIntroduction to jest
Introduction to jestpksjce
 
Saving Time By Testing With Jest
Saving Time By Testing With JestSaving Time By Testing With Jest
Saving Time By Testing With JestBen McCormick
 
Unit and integration Testing
Unit and integration TestingUnit and integration Testing
Unit and integration TestingDavid Berliner
 
What is Regression Testing? | Edureka
What is Regression Testing? | EdurekaWhat is Regression Testing? | Edureka
What is Regression Testing? | EdurekaEdureka!
 
Selenium with Cucumber
Selenium  with Cucumber Selenium  with Cucumber
Selenium with Cucumber Knoldus Inc.
 

Was ist angesagt? (20)

Automated Testing vs Manual Testing
Automated Testing vs Manual TestingAutomated Testing vs Manual Testing
Automated Testing vs Manual Testing
 
Test Automation and Selenium
Test Automation and SeleniumTest Automation and Selenium
Test Automation and Selenium
 
Selenium
SeleniumSelenium
Selenium
 
Introduction to BDD with Cucumber for Java
Introduction to BDD with Cucumber for JavaIntroduction to BDD with Cucumber for Java
Introduction to BDD with Cucumber for Java
 
BDD WITH CUCUMBER AND JAVA
BDD WITH CUCUMBER AND JAVABDD WITH CUCUMBER AND JAVA
BDD WITH CUCUMBER AND JAVA
 
Automated Test Framework with Cucumber
Automated Test Framework with CucumberAutomated Test Framework with Cucumber
Automated Test Framework with Cucumber
 
Manual testing
Manual testingManual testing
Manual testing
 
Introduction to Bdd and cucumber
Introduction to Bdd and cucumberIntroduction to Bdd and cucumber
Introduction to Bdd and cucumber
 
Selenium
SeleniumSelenium
Selenium
 
Browser_Stack_Intro
Browser_Stack_IntroBrowser_Stack_Intro
Browser_Stack_Intro
 
Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)
 
Cucumber ppt
Cucumber pptCucumber ppt
Cucumber ppt
 
Selenium ppt
Selenium pptSelenium ppt
Selenium ppt
 
An overview of selenium webdriver
An overview of selenium webdriverAn overview of selenium webdriver
An overview of selenium webdriver
 
Introduction to jest
Introduction to jestIntroduction to jest
Introduction to jest
 
Saving Time By Testing With Jest
Saving Time By Testing With JestSaving Time By Testing With Jest
Saving Time By Testing With Jest
 
Unit and integration Testing
Unit and integration TestingUnit and integration Testing
Unit and integration Testing
 
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
 
What is Regression Testing? | Edureka
What is Regression Testing? | EdurekaWhat is Regression Testing? | Edureka
What is Regression Testing? | Edureka
 
Selenium with Cucumber
Selenium  with Cucumber Selenium  with Cucumber
Selenium with Cucumber
 

Ähnlich wie 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
 

Ähnlich wie 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...
 

Kürzlich hochgeladen

Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
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
 
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
 
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
 
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.
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceanilsa9823
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
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
 
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
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
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
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
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
 
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
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 

Kürzlich hochgeladen (20)

Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
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 ...
 
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
 
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
 
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...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
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 ...
 
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
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
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...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
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
 
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
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 

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