SlideShare a Scribd company logo
1 of 118
Download to read offline
Behat from zero to hero
“A practical guide to symfony integration and usage”
Matteo Moretti - Samuele Lilli@SymfonyDayIt - 20 Ottobre 2017 - Milano
Matteo Moretti | Samuele Lilli
WHO ARE WE?
Matteo Moretti Samuele Lilli
Matteo Moretti | Samuele Lilli
OUR
EXPERIENCE
Matteo Moretti | Samuele Lilli
OUR EXPERIENCE
ON nuvola.madisoft.it
https://symfony.com/showcase/191
Matteo Moretti | Samuele Lilli
BEHAVIOUR
DRIVEN
DEVELOPMENT
Matteo Moretti | Samuele Lilli
BEHAT
Matteo Moretti | Samuele Lilli
A LONG TIME
AGO ...
Matteo Moretti | Samuele Lilli
Matteo Moretti | Samuele Lilli
Matteo Moretti | Samuele Lilli
TESTS ARE GREEN!
Matteo Moretti | Samuele Lilli
BUT,
SUDDENLY...
Matteo Moretti | Samuele Lilli
AS SOON AS
YOU ADD MORE
TESTS...
Matteo Moretti | Samuele Lilli
HARD TO MAINTAIN
Matteo Moretti | Samuele Lilli
RANDOM
FAILURES
Matteo Moretti | Samuele Lilli
SLOW TESTS
Matteo Moretti | Samuele Lilli
“WHY THE HELL THIS
TEST IS BROKEN?
I DIDN’T MODIFY THAT
CODE”
Matteo Moretti | Samuele Lilli
“MMM, 10 MINUTES TO
ADD A FEATURE. 2
HOURS TO FIX TESTS.”
Matteo Moretti | Samuele Lilli
Matteo Moretti | Samuele Lilli
Matteo Moretti | Samuele Lilli
WHAT IS
BEHAT?
Matteo Moretti | Samuele Lilli
IT’S A BDD TOOL!
Matteo Moretti | Samuele Lilli
IT’S A
STORY
BDD TOOL!
Matteo Moretti | Samuele Lilli
WHAT IS A
STORY?
Matteo Moretti | Samuele Lilli
HI! I’M A STORY!
Matteo Moretti | Samuele Lilli
EXAMPLE OF HOW THE SYSTEM SHOULD BEHAVE
DESCRIPTION OF A GIVEN REQUIREMENT IN UBIQUITOUS NATURAL LANGUAGE
UNDERSTANDABLE BY ALL STAKEHOLDERS OF THE PROJECT
ACCEPTANCE TEST
DOCUMENTATION THAT NEVER GOES OUT TO DATE
WRITTEN IN GHERKIN
EXECUTABLE SPECIFICATION
A STORY IS ...
Matteo Moretti | Samuele Lilli
EXAMPLE OF HOW THE SYSTEM SHOULD BEHAVE
DESCRIPTION OF A GIVEN REQUIREMENT IN UBIQUITOUS NATURAL LANGUAGE
UNDERSTANDABLE BY ALL STAKEHOLDERS OF THE PROJECT
ACCEPTANCE TEST
DOCUMENTATION THAT NEVER GOES OUT TO DATE
WRITTEN IN GHERKIN
EXECUTABLE SPECIFICATION
A STORY IS ...
Matteo Moretti | Samuele Lilli
EXAMPLE OF HOW THE SYSTEM SHOULD BEHAVE
DESCRIPTION OF A GIVEN REQUIREMENT IN UBIQUITOUS NATURAL LANGUAGE
UNDERSTANDABLE BY ALL STAKEHOLDERS OF THE PROJECT
ACCEPTANCE TEST
DOCUMENTATION THAT NEVER GOES OUT TO DATE
WRITTEN IN GHERKIN
EXECUTABLE SPECIFICATION
A STORY IS ...
Matteo Moretti | Samuele Lilli
EXAMPLE OF HOW THE SYSTEM SHOULD BEHAVE
DESCRIPTION OF A GIVEN REQUIREMENT IN UBIQUITOUS NATURAL LANGUAGE
UNDERSTANDABLE BY ALL STAKEHOLDERS OF THE PROJECT
ACCEPTANCE TEST
DOCUMENTATION THAT NEVER GOES OUT TO DATE
WRITTEN IN GHERKIN
EXECUTABLE SPECIFICATION
A STORY IS ...
Matteo Moretti | Samuele Lilli
EXAMPLE OF HOW THE SYSTEM SHOULD BEHAVE
DESCRIPTION OF A GIVEN REQUIREMENT IN UBIQUITOUS NATURAL LANGUAGE
UNDERSTANDABLE BY ALL STAKEHOLDERS OF THE PROJECT
ACCEPTANCE TEST
DOCUMENTATION THAT NEVER GOES OUT TO DATE
WRITTEN IN GHERKIN
EXECUTABLE SPECIFICATION
A STORY IS ...
Matteo Moretti | Samuele Lilli
EXAMPLE OF HOW THE SYSTEM SHOULD BEHAVE
DESCRIPTION OF A GIVEN REQUIREMENT IN UBIQUITOUS NATURAL LANGUAGE
UNDERSTANDABLE BY ALL STAKEHOLDERS OF THE PROJECT
ACCEPTANCE TEST
DOCUMENTATION THAT NEVER GOES OUT TO DATE
WRITTEN IN GHERKIN
EXECUTABLE SPECIFICATION
A STORY IS ...
Matteo Moretti | Samuele Lilli
EXAMPLE OF HOW THE SYSTEM SHOULD BEHAVE
DESCRIPTION OF A GIVEN REQUIREMENT IN UBIQUITOUS NATURAL LANGUAGE
UNDERSTANDABLE BY ALL STAKEHOLDERS OF THE PROJECT
ACCEPTANCE TEST
DOCUMENTATION THAT NEVER GOES OUT TO DATE
WRITTEN IN GHERKIN
EXECUTABLE SPECIFICATION
A STORY IS ...
Matteo Moretti | Samuele Lilli
GHERKIN
Matteo Moretti | Samuele Lilli
IT’S A LANGUAGE!
Matteo Moretti | Samuele Lilli
IT’S A BUSINESS
READABLE
DOMAIN SPECIFIC
LANGUAGE!
Matteo Moretti | Samuele Lilli
LIKE YAML
INDENTATION
RULES PARSING
Matteo Moretti | Samuele Lilli
STORIES ARE ORGANIZED IN
FEATURES FILES (.feature)
Matteo Moretti | Samuele Lilli
GIVEN - WHEN - THEN
(AND, BUT) ARE KEYWORDS
THAT MATCH PHP CODE
AND EXECUTE IT.
STEPS
Matteo Moretti | Samuele Lilli
Matteo Moretti | Samuele Lilli
REGEX
Matteo Moretti | Samuele Lilli
Matteo Moretti | Samuele Lilli
Matteo Moretti | Samuele Lilli
Matteo Moretti | Samuele Lilli
ISSUES
HARD TO MAINTAIN
RANDOM FAILURES
SLOW TESTS
Matteo Moretti | Samuele Lilli
ISSUES
HARD TO MAINTAIN
RANDOM FAILURES
SLOW TESTS
Matteo Moretti | Samuele Lilli
HOW A GOOD
STORY LOOKS
LIKE?
Matteo Moretti | Samuele Lilli
FOCUS ON OUTPUT NOT INPUT
X
Matteo Moretti | Samuele Lilli
√
FOCUS ON OUTPUT NOT INPUT
Matteo Moretti | Samuele Lilli
DON’T USE UI REFERENCES
X
Matteo Moretti | Samuele Lilli
DON’T USE UI REFERENCES
√
Matteo Moretti | Samuele Lilli
USE BACKGROUND
Matteo Moretti | Samuele Lilli
USE TRANSFORMERS
Matteo Moretti | Samuele Lilli
USE TRANSFORMERS
Matteo Moretti | Samuele Lilli
COLLAPSE STEPS AS MUCH AS
POSSIBLE
UNLESS THESE GIVES YOU
BUSINESS/STORY VALUE
Matteo Moretti | Samuele Lilli
Matteo Moretti | Samuele Lilli
HOW
MUCH
DETAILS?
Matteo Moretti | Samuele Lilli
“What many people don’t realize is that
different levels of details are appropriate
for different scenarios in the same system
- sometimes in the same feature -
depending on what it is they’re describing”
(The cucumber book - Matt Wynne, Aslak Hellesoy)
Matteo Moretti | Samuele Lilli
BEHAT → GHERKIN → FEATURES →
STORIES (SCENARIOS) → STEPS →
CONTEXTS
Matteo Moretti | Samuele Lilli
BEHAT → GHERKIN → FEATURES →
STORIES (SCENARIOS) → STEPS →
CONTEXTS
Matteo Moretti | Samuele Lilli
DIVIDE ET IMPERA
Matteo Moretti | Samuele Lilli
ONE FEATURE
PER .FEATURE FILE
Matteo Moretti | Samuele Lilli
DIVIDE FEATURES
AND CONTEXTS
BY DOMAIN SUBJECT
Matteo Moretti | Samuele Lilli
DIVIDE FEATURES
AND CONTEXTS
BY ACTIONS TO BE
PERFORMED ON
DOMAIN SUBJECTS
Matteo Moretti | Samuele Lilli
Matteo Moretti | Samuele Lilli
Matteo Moretti | Samuele Lilli
UI
Matteo Moretti | Samuele Lilli
HEADLESS BROWSER EMULATOR
VS
BROWSER CONTROLLER
Matteo Moretti | Samuele Lilli
HEADLESS BROWSER EMULATOR
● pure HTTP spec implementations
● very simple to run and configure
● no need of a real browser: speed
● usually no JS/AJAX support
Matteo Moretti | Samuele Lilli
BROWSER CONTROLLER
● aim to control a real browser
● complex to configure
● slow
● JS/AJAX support
Matteo Moretti | Samuele Lilli
YOU MAY NEED BOTH OF THEM
Matteo Moretti | Samuele Lilli
MINK
http://mink.behat.org/en/latest/
Matteo Moretti | Samuele Lilli
BEHAT PARSES SCENARIOS
+
MINK BROWSES THE WEB
Matteo Moretti | Samuele Lilli
Matteo Moretti | Samuele Lilli
ISSUES
HARD TO MAINTAIN
RANDOM FAILURES
SLOW TESTS
Matteo Moretti | Samuele Lilli
HOW TO USE MINK
FROM CONTEXT
CLASSES?
Matteo Moretti | Samuele Lilli
PAGE OBJECT PATTERN
https://martinfowler.com/bliki/PageObject.html
Matteo Moretti | Samuele Lilli
https://github.com/sensiolabs/BehatPageObjectExtension
BEHAT PAGE OBJECT EXTENSION
Matteo Moretti | Samuele Lilli
ASSERTIONS
Matteo Moretti | Samuele Lilli
ISSUES
HARD TO MAINTAIN
RANDOM FAILURES
SLOW TESTS
Matteo Moretti | Samuele Lilli
ISSUES
HARD TO MAINTAIN
RANDOM FAILURES
SLOW TESTS
Matteo Moretti | Samuele Lilli
AJAX
Matteo Moretti | Samuele Lilli
DON’T PULL YOUR
TESTS WITH SLEEP()
CALLS
Matteo Moretti | Samuele Lilli
ISSUES
HARD TO MAINTAIN
RANDOM FAILURES
SLOW TESTS
Matteo Moretti | Samuele Lilli
ISSUES
HARD TO MAINTAIN
RANDOM FAILURES
SLOW TESTS
Matteo Moretti | Samuele Lilli
UI END-TO-END TESTS
● BRITTLE
● EXPENSIVE TO WRITE
● TIME CONSUMING TO RUN
● MORE AFFECTED BY NON-DETERMINISM
Matteo Moretti | Samuele Lilli
Matteo Moretti | Samuele Lilli
https://martinfowler.com/bliki/TestPyramid.html
Matteo Moretti | Samuele Lilli
DO YOU REALLY NEED A REAL JS BROWSER?
https://blog.eleven-labs.com/en/behat-structure-functional-tests/
Matteo Moretti | Samuele Lilli
STICK TO A BROWSER EMULATOR
USE @javascript ONLY WHEN NEEDED
Matteo Moretti | Samuele Lilli
FIXTURES DATA
● NO FIXTURES (INTEGRATION TESTS)
● LOAD FIXTURES AT RUNTIME
● IN MEMORY DBMS (SQLITE)
Matteo Moretti | Samuele Lilli
PARALLELISM
● SPEED UP PERFORMANCE
● COMPLEX SETUP AND DEBUG
DO YOU NEED IT?
Matteo Moretti | Samuele Lilli
FASTEST
https://github.com/liuggio/fastest
bin/behat --list-scenarios --config
tests/behat/behat.yml | bin/fastest -vv --process=4
"bin/behat --stop-on-failure --config
tests/behat/behat.yml {}"
Matteo Moretti | Samuele Lilli
ISSUES
HARD TO MAINTAIN
RANDOM FAILURES
SLOW TESTS
Matteo Moretti | Samuele Lilli
SAVE OUTPUT FOR
FAILED TESTS
Matteo Moretti | Samuele Lilli
DEBUG
Matteo Moretti | Samuele Lilli
CLI DEBUG
● BEHAT CODE
● APP CODE IF INTEGRATION TEST (NO UI)
● APP CODE IF UI TESTS WITH BROWSER
EMULATOR (BrowserKit)
Matteo Moretti | Samuele Lilli
WEB DEBUG
FOR APP CODE IF BROWSER CONTROLLER
(SELENIUM)
Matteo Moretti | Samuele Lilli
RECAP
Matteo Moretti | Samuele Lilli
TREAT YOUR TEST
CODE AS YOUR
APP (PROD) CODE
Matteo Moretti | Samuele Lilli
WRITE CLEAN,
CONCISE AND
WELL ORGANIZED
FEATURES
Matteo Moretti | Samuele Lilli
SPLIT YOUR
CONTEXT CLASSES
AND
COMPOSE / REUSE
THEM
Matteo Moretti | Samuele Lilli
REMEMBER TEST PYRAMID
FOCUS ON INTEGRATION LEVEL
Matteo Moretti | Samuele Lilli
USE @javascript WISELY
USE PAGE OBJECTS FOR UI
Matteo Moretti | Samuele Lilli
THANK YOU
Matteo Moretti | Samuele Lilli
WE ARE HIRING!
(wanna join? ask us or visit our website)
labs.madisoft.it
Matteo Moretti | Samuele Lilli
https://joind.in/talk/707a1
QUESTIONS?

More Related Content

Recently uploaded

Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Mater
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfkalichargn70th171
 
Software Coding for software engineering
Software Coding for software engineeringSoftware Coding for software engineering
Software Coding for software engineeringssuserb3a23b
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentationvaddepallysandeep122
 
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
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
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
 
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
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
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
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 

Recently uploaded (20)

Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
 
Software Coding for software engineering
Software Coding for software engineeringSoftware Coding for software engineering
Software Coding for software engineering
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
 
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...
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
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...
 
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
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
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...
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Behat from zero to hero: "a practical guide to Symfony integration and usage"

  • 1. Behat from zero to hero “A practical guide to symfony integration and usage” Matteo Moretti - Samuele Lilli@SymfonyDayIt - 20 Ottobre 2017 - Milano
  • 2. Matteo Moretti | Samuele Lilli WHO ARE WE? Matteo Moretti Samuele Lilli
  • 3. Matteo Moretti | Samuele Lilli OUR EXPERIENCE
  • 4. Matteo Moretti | Samuele Lilli OUR EXPERIENCE ON nuvola.madisoft.it https://symfony.com/showcase/191
  • 5. Matteo Moretti | Samuele Lilli BEHAVIOUR DRIVEN DEVELOPMENT
  • 6. Matteo Moretti | Samuele Lilli BEHAT
  • 7. Matteo Moretti | Samuele Lilli A LONG TIME AGO ...
  • 8. Matteo Moretti | Samuele Lilli
  • 9. Matteo Moretti | Samuele Lilli
  • 10. Matteo Moretti | Samuele Lilli TESTS ARE GREEN!
  • 11.
  • 12. Matteo Moretti | Samuele Lilli BUT, SUDDENLY...
  • 13. Matteo Moretti | Samuele Lilli AS SOON AS YOU ADD MORE TESTS...
  • 14. Matteo Moretti | Samuele Lilli HARD TO MAINTAIN
  • 15. Matteo Moretti | Samuele Lilli RANDOM FAILURES
  • 16. Matteo Moretti | Samuele Lilli SLOW TESTS
  • 17.
  • 18. Matteo Moretti | Samuele Lilli “WHY THE HELL THIS TEST IS BROKEN? I DIDN’T MODIFY THAT CODE”
  • 19. Matteo Moretti | Samuele Lilli “MMM, 10 MINUTES TO ADD A FEATURE. 2 HOURS TO FIX TESTS.”
  • 20.
  • 21. Matteo Moretti | Samuele Lilli
  • 22. Matteo Moretti | Samuele Lilli
  • 23. Matteo Moretti | Samuele Lilli WHAT IS BEHAT?
  • 24. Matteo Moretti | Samuele Lilli IT’S A BDD TOOL!
  • 25. Matteo Moretti | Samuele Lilli IT’S A STORY BDD TOOL!
  • 26. Matteo Moretti | Samuele Lilli WHAT IS A STORY?
  • 27. Matteo Moretti | Samuele Lilli HI! I’M A STORY!
  • 28. Matteo Moretti | Samuele Lilli EXAMPLE OF HOW THE SYSTEM SHOULD BEHAVE DESCRIPTION OF A GIVEN REQUIREMENT IN UBIQUITOUS NATURAL LANGUAGE UNDERSTANDABLE BY ALL STAKEHOLDERS OF THE PROJECT ACCEPTANCE TEST DOCUMENTATION THAT NEVER GOES OUT TO DATE WRITTEN IN GHERKIN EXECUTABLE SPECIFICATION A STORY IS ...
  • 29. Matteo Moretti | Samuele Lilli EXAMPLE OF HOW THE SYSTEM SHOULD BEHAVE DESCRIPTION OF A GIVEN REQUIREMENT IN UBIQUITOUS NATURAL LANGUAGE UNDERSTANDABLE BY ALL STAKEHOLDERS OF THE PROJECT ACCEPTANCE TEST DOCUMENTATION THAT NEVER GOES OUT TO DATE WRITTEN IN GHERKIN EXECUTABLE SPECIFICATION A STORY IS ...
  • 30. Matteo Moretti | Samuele Lilli EXAMPLE OF HOW THE SYSTEM SHOULD BEHAVE DESCRIPTION OF A GIVEN REQUIREMENT IN UBIQUITOUS NATURAL LANGUAGE UNDERSTANDABLE BY ALL STAKEHOLDERS OF THE PROJECT ACCEPTANCE TEST DOCUMENTATION THAT NEVER GOES OUT TO DATE WRITTEN IN GHERKIN EXECUTABLE SPECIFICATION A STORY IS ...
  • 31. Matteo Moretti | Samuele Lilli EXAMPLE OF HOW THE SYSTEM SHOULD BEHAVE DESCRIPTION OF A GIVEN REQUIREMENT IN UBIQUITOUS NATURAL LANGUAGE UNDERSTANDABLE BY ALL STAKEHOLDERS OF THE PROJECT ACCEPTANCE TEST DOCUMENTATION THAT NEVER GOES OUT TO DATE WRITTEN IN GHERKIN EXECUTABLE SPECIFICATION A STORY IS ...
  • 32. Matteo Moretti | Samuele Lilli EXAMPLE OF HOW THE SYSTEM SHOULD BEHAVE DESCRIPTION OF A GIVEN REQUIREMENT IN UBIQUITOUS NATURAL LANGUAGE UNDERSTANDABLE BY ALL STAKEHOLDERS OF THE PROJECT ACCEPTANCE TEST DOCUMENTATION THAT NEVER GOES OUT TO DATE WRITTEN IN GHERKIN EXECUTABLE SPECIFICATION A STORY IS ...
  • 33. Matteo Moretti | Samuele Lilli EXAMPLE OF HOW THE SYSTEM SHOULD BEHAVE DESCRIPTION OF A GIVEN REQUIREMENT IN UBIQUITOUS NATURAL LANGUAGE UNDERSTANDABLE BY ALL STAKEHOLDERS OF THE PROJECT ACCEPTANCE TEST DOCUMENTATION THAT NEVER GOES OUT TO DATE WRITTEN IN GHERKIN EXECUTABLE SPECIFICATION A STORY IS ...
  • 34. Matteo Moretti | Samuele Lilli EXAMPLE OF HOW THE SYSTEM SHOULD BEHAVE DESCRIPTION OF A GIVEN REQUIREMENT IN UBIQUITOUS NATURAL LANGUAGE UNDERSTANDABLE BY ALL STAKEHOLDERS OF THE PROJECT ACCEPTANCE TEST DOCUMENTATION THAT NEVER GOES OUT TO DATE WRITTEN IN GHERKIN EXECUTABLE SPECIFICATION A STORY IS ...
  • 35. Matteo Moretti | Samuele Lilli GHERKIN
  • 36. Matteo Moretti | Samuele Lilli IT’S A LANGUAGE!
  • 37. Matteo Moretti | Samuele Lilli IT’S A BUSINESS READABLE DOMAIN SPECIFIC LANGUAGE!
  • 38.
  • 39. Matteo Moretti | Samuele Lilli LIKE YAML INDENTATION RULES PARSING
  • 40. Matteo Moretti | Samuele Lilli STORIES ARE ORGANIZED IN FEATURES FILES (.feature)
  • 41. Matteo Moretti | Samuele Lilli GIVEN - WHEN - THEN (AND, BUT) ARE KEYWORDS THAT MATCH PHP CODE AND EXECUTE IT. STEPS
  • 42. Matteo Moretti | Samuele Lilli
  • 43.
  • 44. Matteo Moretti | Samuele Lilli REGEX
  • 45. Matteo Moretti | Samuele Lilli
  • 46. Matteo Moretti | Samuele Lilli
  • 47. Matteo Moretti | Samuele Lilli
  • 48. Matteo Moretti | Samuele Lilli ISSUES HARD TO MAINTAIN RANDOM FAILURES SLOW TESTS
  • 49. Matteo Moretti | Samuele Lilli ISSUES HARD TO MAINTAIN RANDOM FAILURES SLOW TESTS
  • 50. Matteo Moretti | Samuele Lilli HOW A GOOD STORY LOOKS LIKE?
  • 51. Matteo Moretti | Samuele Lilli FOCUS ON OUTPUT NOT INPUT X
  • 52. Matteo Moretti | Samuele Lilli √ FOCUS ON OUTPUT NOT INPUT
  • 53. Matteo Moretti | Samuele Lilli DON’T USE UI REFERENCES X
  • 54. Matteo Moretti | Samuele Lilli DON’T USE UI REFERENCES √
  • 55. Matteo Moretti | Samuele Lilli USE BACKGROUND
  • 56. Matteo Moretti | Samuele Lilli USE TRANSFORMERS
  • 57. Matteo Moretti | Samuele Lilli USE TRANSFORMERS
  • 58. Matteo Moretti | Samuele Lilli COLLAPSE STEPS AS MUCH AS POSSIBLE UNLESS THESE GIVES YOU BUSINESS/STORY VALUE
  • 59. Matteo Moretti | Samuele Lilli
  • 60. Matteo Moretti | Samuele Lilli HOW MUCH DETAILS?
  • 61. Matteo Moretti | Samuele Lilli “What many people don’t realize is that different levels of details are appropriate for different scenarios in the same system - sometimes in the same feature - depending on what it is they’re describing” (The cucumber book - Matt Wynne, Aslak Hellesoy)
  • 62. Matteo Moretti | Samuele Lilli BEHAT → GHERKIN → FEATURES → STORIES (SCENARIOS) → STEPS → CONTEXTS
  • 63. Matteo Moretti | Samuele Lilli BEHAT → GHERKIN → FEATURES → STORIES (SCENARIOS) → STEPS → CONTEXTS
  • 64. Matteo Moretti | Samuele Lilli DIVIDE ET IMPERA
  • 65. Matteo Moretti | Samuele Lilli ONE FEATURE PER .FEATURE FILE
  • 66. Matteo Moretti | Samuele Lilli DIVIDE FEATURES AND CONTEXTS BY DOMAIN SUBJECT
  • 67. Matteo Moretti | Samuele Lilli DIVIDE FEATURES AND CONTEXTS BY ACTIONS TO BE PERFORMED ON DOMAIN SUBJECTS
  • 68. Matteo Moretti | Samuele Lilli
  • 69. Matteo Moretti | Samuele Lilli
  • 70. Matteo Moretti | Samuele Lilli UI
  • 71. Matteo Moretti | Samuele Lilli HEADLESS BROWSER EMULATOR VS BROWSER CONTROLLER
  • 72. Matteo Moretti | Samuele Lilli HEADLESS BROWSER EMULATOR ● pure HTTP spec implementations ● very simple to run and configure ● no need of a real browser: speed ● usually no JS/AJAX support
  • 73. Matteo Moretti | Samuele Lilli BROWSER CONTROLLER ● aim to control a real browser ● complex to configure ● slow ● JS/AJAX support
  • 74.
  • 75. Matteo Moretti | Samuele Lilli YOU MAY NEED BOTH OF THEM
  • 76. Matteo Moretti | Samuele Lilli MINK http://mink.behat.org/en/latest/
  • 77. Matteo Moretti | Samuele Lilli BEHAT PARSES SCENARIOS + MINK BROWSES THE WEB
  • 78.
  • 79. Matteo Moretti | Samuele Lilli
  • 80. Matteo Moretti | Samuele Lilli ISSUES HARD TO MAINTAIN RANDOM FAILURES SLOW TESTS
  • 81. Matteo Moretti | Samuele Lilli HOW TO USE MINK FROM CONTEXT CLASSES?
  • 82. Matteo Moretti | Samuele Lilli PAGE OBJECT PATTERN https://martinfowler.com/bliki/PageObject.html
  • 83.
  • 84.
  • 85. Matteo Moretti | Samuele Lilli https://github.com/sensiolabs/BehatPageObjectExtension BEHAT PAGE OBJECT EXTENSION
  • 86. Matteo Moretti | Samuele Lilli ASSERTIONS
  • 87.
  • 88. Matteo Moretti | Samuele Lilli ISSUES HARD TO MAINTAIN RANDOM FAILURES SLOW TESTS
  • 89. Matteo Moretti | Samuele Lilli ISSUES HARD TO MAINTAIN RANDOM FAILURES SLOW TESTS
  • 90. Matteo Moretti | Samuele Lilli AJAX
  • 91. Matteo Moretti | Samuele Lilli DON’T PULL YOUR TESTS WITH SLEEP() CALLS
  • 92.
  • 93. Matteo Moretti | Samuele Lilli ISSUES HARD TO MAINTAIN RANDOM FAILURES SLOW TESTS
  • 94. Matteo Moretti | Samuele Lilli ISSUES HARD TO MAINTAIN RANDOM FAILURES SLOW TESTS
  • 95. Matteo Moretti | Samuele Lilli UI END-TO-END TESTS ● BRITTLE ● EXPENSIVE TO WRITE ● TIME CONSUMING TO RUN ● MORE AFFECTED BY NON-DETERMINISM
  • 96. Matteo Moretti | Samuele Lilli
  • 97. Matteo Moretti | Samuele Lilli https://martinfowler.com/bliki/TestPyramid.html
  • 98. Matteo Moretti | Samuele Lilli DO YOU REALLY NEED A REAL JS BROWSER? https://blog.eleven-labs.com/en/behat-structure-functional-tests/
  • 99. Matteo Moretti | Samuele Lilli STICK TO A BROWSER EMULATOR USE @javascript ONLY WHEN NEEDED
  • 100. Matteo Moretti | Samuele Lilli FIXTURES DATA ● NO FIXTURES (INTEGRATION TESTS) ● LOAD FIXTURES AT RUNTIME ● IN MEMORY DBMS (SQLITE)
  • 101. Matteo Moretti | Samuele Lilli PARALLELISM ● SPEED UP PERFORMANCE ● COMPLEX SETUP AND DEBUG DO YOU NEED IT?
  • 102. Matteo Moretti | Samuele Lilli FASTEST https://github.com/liuggio/fastest bin/behat --list-scenarios --config tests/behat/behat.yml | bin/fastest -vv --process=4 "bin/behat --stop-on-failure --config tests/behat/behat.yml {}"
  • 103. Matteo Moretti | Samuele Lilli ISSUES HARD TO MAINTAIN RANDOM FAILURES SLOW TESTS
  • 104. Matteo Moretti | Samuele Lilli SAVE OUTPUT FOR FAILED TESTS
  • 105.
  • 106. Matteo Moretti | Samuele Lilli DEBUG
  • 107. Matteo Moretti | Samuele Lilli CLI DEBUG ● BEHAT CODE ● APP CODE IF INTEGRATION TEST (NO UI) ● APP CODE IF UI TESTS WITH BROWSER EMULATOR (BrowserKit)
  • 108. Matteo Moretti | Samuele Lilli WEB DEBUG FOR APP CODE IF BROWSER CONTROLLER (SELENIUM)
  • 109. Matteo Moretti | Samuele Lilli RECAP
  • 110. Matteo Moretti | Samuele Lilli TREAT YOUR TEST CODE AS YOUR APP (PROD) CODE
  • 111. Matteo Moretti | Samuele Lilli WRITE CLEAN, CONCISE AND WELL ORGANIZED FEATURES
  • 112. Matteo Moretti | Samuele Lilli SPLIT YOUR CONTEXT CLASSES AND COMPOSE / REUSE THEM
  • 113. Matteo Moretti | Samuele Lilli REMEMBER TEST PYRAMID FOCUS ON INTEGRATION LEVEL
  • 114. Matteo Moretti | Samuele Lilli USE @javascript WISELY USE PAGE OBJECTS FOR UI
  • 115. Matteo Moretti | Samuele Lilli THANK YOU
  • 116. Matteo Moretti | Samuele Lilli WE ARE HIRING! (wanna join? ask us or visit our website) labs.madisoft.it
  • 117. Matteo Moretti | Samuele Lilli https://joind.in/talk/707a1