SlideShare ist ein Scribd-Unternehmen logo
1 von 66
Page | 1
Where have we been and what
do we do?
The Future of
Testing Magento 2
Page | 2
About Me
James Cowie
● CTO @ Shero Commerce
● Magento Master
● BDD / TDD advocate
● @jcowie
● @sherocommerce
Page | 3Page | 3
➔ “The process of learning effective TDD is the process of
learning how to build more modular applications.”
The Goal
Page | 4Page | 4
➔ “The process of learning effective TDD is the process of
learning how to build more modular applications.”
The Goal
Page | 5
The Reasons to not test
➔ We don't have the budget!
➔ We don’t have the time!
➔ Testing slows us down!
➔ We don’t have the training!
➔ It gets in the way!
➔ The client won’t pay for it!
➔ The tests become out of date
➔ They run slow and hold us back!
➔ Ship first test later
Page | 6
Group the historical reasons
Time Knowledge Understanding
Testing slows us down! We don’t have the training! Ship first test later
We don’t have the time! The tests become out of date They run slow and hold us back!
We don't have the budget! Ship first test later
The client won’t pay for it!
Page | 7Page | 7
Time
Page | 8
Time to add features over time
without tests
● Faster to start with
● Slows down due to large code
● More time spent manual testing
● Higher chance of defects
Page | 9
Time to add features over time with
tests
● Does add time initially
● Get faster for feature development
● Less chance of defects
● Better use of time on exploratory
testing
● More maintainable
Page | 10
Time Conclusion
Testing slows us down
Over time testing speeds you up.
We don’t have time
Having tests will shorten delivery time making more
time.
The client won’t pay for it
Clients don’t need to know how you cook the steak.
Instead, they will pay for excellence and high quality.
Page | 11Page | 11
Knowledge
Page | 12
Knowledge. The hard truth
➔ Testing is _hard_
➔ Architecture can hinder
➔ Complete mind shift
➔ Is a whole team sport
Page | 13
Knowledge. Current design
Page | 14
Knowledge. Current design
Page | 15
Has this been solved before?
➔ Ports and Adaptors
➔ Hexagonal Architecture
➔ DDD
Alistair, Cockburn (2005-04-01). "Hexagonal architecture". alistair.cockburn.us.
Page | 16
Knowledge. Future design
Page | 17
Knowledge. Future design
Adaptor
Port
Page | 18
Ports
➔ Slim Magento 2 module
➔ Contains no business logic
➔ Traditional Magento 2 module
Page | 19
Adaptors
➔ The custom implementation,
➔ Business logic
➔ Dependency inverted,
➔ Injectable
Page | 20
The Bridge
➔ Can be an API
➔ Dependency Injection into slim Magento 2 client
➔ Responsible for linking the 2 systems
Page | 21Page | 21
Types of testing
Page | 22
Types of testing
➔ Unit Testing
➔ Integration Testing
➔ Acceptance Testing
Page | 23
Unit Testing
➔ Internal testing (Inwards)
Page | 24
Integration Testing
➔ Outside facing testing (outwards)
Page | 25
Acceptance Testing
➔ Does it work?
Page | 26
What tools are available?
Page | 27
Pick the right tool for your team
➔ Not all tools are equal,
➔ Varying levels of effort and knowledge,
➔ Used in different scenarios.
Page | 28
Behaviour Driven Development (BDD)
Page | 29
More traditional TDD
Page | 30
What hinders testing?
➔ Inheritance
➔ Tight Coupling
➔ Testing after concrete code is wrote
Page | 31
Favour Composition
• Blueprints to the concrete
implementation
• Describe functionality.
Page | 32Page | 32
TDD workflow
Page | 33
The TDD dance
Page | 34
The TDD dance
Write a failing test
Page | 35
The TDD dance
Write just enough
code to make the
test pass
Page | 36
The TDD dance
Refactor the code
to be complete
Page | 37
Think design / architecture
➔ Your only thinking about small units,
➔ Refactoring is safe,
➔ Your designing with interfaces,
➔ Stops gold plating.
Page | 38Page | 38
• This is a simple module but should highlight how simple
setup can be.
Lets see this in practice
Page | 39
The module / Demo
PayMate LTD provides the ability to part pay for goods and
split it over a number of months. They handle the payment
side of the process but they need the product details page to
show the split. The business rules are:
• Products under $50 can be split into 2 monthly payments
• Products under $200 can be split into 4 monthly payments
• Products over $500 can NOT be split
Page | 40
Code Structure
Page | 41
Bootstrapping
Page | 42
Failing Testing
Fail
Page | 43
Failing Testing
Fail
Page | 44
Failing Testing
Fail
Page | 45
Make it green (small increment)
Pass
Page | 46
Make it green (small increment)
Pass
Page | 47
Failing Testing
Fail
Page | 48
Failing Testing
Fail
Page | 49
Write just enough code to make it
pass
Pass
Page | 50
Failing Testing
Fail
Page | 51
Failing Testing
Fail
Page | 52
Write just enough code to make it
pass
Pass
Page | 53
Introduce a Mock
Page | 54
Using the mock to get price
Page | 55
v
Disclaimer
The way I use the registry is NOT complete
and also bad practice.
Page | 56
Make it do something
Page | 57
Integration testing
Page | 58
Integration testing
Page | 59
Integration testing
Page | 60
Integration testing
Page | 61
Integration testing
➔ Mink offers helpers
➔ Use a Magento driver
Page | 62
Refactoring Step
➔ Now that the tests pass Refactor!
➔ Remove the hard values for dynamic
➔ Keep running the tests
Page | 63
Integration testing
➔ Behat runs via Selenium
➔ The feature context is the powerhouse
➔ Its slower than Unit tests
➔ Can be optimized via Behat plugins
Page | 64
v
Overview of our testing
PHPUnit
Behat
Core Domain
Page | 65
Where to go from here?
➔ To team code katas
➔ Keep practicing
➔ Watch Vinai’s kata series
➔ Watch out for Fabian Schmengler book
Page | 66
Thank You

Weitere ähnliche Inhalte

Was ist angesagt?

Practical way to experience of Specification by Example
Practical way to experience of Specification by ExamplePractical way to experience of Specification by Example
Practical way to experience of Specification by ExampleLarry Cai
 
Agile testingandautomation
Agile testingandautomationAgile testingandautomation
Agile testingandautomationjeisner
 
Specification by Example - Agile India 2015
Specification by Example - Agile India 2015Specification by Example - Agile India 2015
Specification by Example - Agile India 2015Ankur Sambhar
 
How testers add value to the organization appium conf
How testers add value to the organization  appium confHow testers add value to the organization  appium conf
How testers add value to the organization appium confCorina Pip
 
Behavior driven development - cucumber, Junit and java
Behavior driven development - cucumber, Junit and javaBehavior driven development - cucumber, Junit and java
Behavior driven development - cucumber, Junit and javaNaveen Kumar Singh
 
ALE15 The real value of a definition of done
ALE15  The real value of a definition of doneALE15  The real value of a definition of done
ALE15 The real value of a definition of doneChristian Vos
 
Identifying and measuring testing debt
Identifying and measuring testing debtIdentifying and measuring testing debt
Identifying and measuring testing debtPeter Varhol
 
Test Driven Development – how it benefits business and teams alike
Test Driven Development – how it benefits business and teams alikeTest Driven Development – how it benefits business and teams alike
Test Driven Development – how it benefits business and teams alikeScrum Australia Pty Ltd
 
Desire2Learn Conversion Labs: Fishing for Early Adopters
Desire2Learn Conversion Labs: Fishing for Early AdoptersDesire2Learn Conversion Labs: Fishing for Early Adopters
Desire2Learn Conversion Labs: Fishing for Early Adoptersjlknott
 
Reduce WIP and Deliver Often: Kanban Recipe for Success Steps 2 and 3
Reduce WIP and Deliver Often: Kanban Recipe for Success Steps 2 and 3Reduce WIP and Deliver Often: Kanban Recipe for Success Steps 2 and 3
Reduce WIP and Deliver Often: Kanban Recipe for Success Steps 2 and 3Jason Yip
 
Session on Look beyond what the eyes can see- Reviving Visual validations by ...
Session on Look beyond what the eyes can see- Reviving Visual validations by ...Session on Look beyond what the eyes can see- Reviving Visual validations by ...
Session on Look beyond what the eyes can see- Reviving Visual validations by ...Agile Testing Alliance
 
Building Cross-Functional Scrum-Teams in a Hardware Project
Building Cross-Functional Scrum-Teams in a Hardware ProjectBuilding Cross-Functional Scrum-Teams in a Hardware Project
Building Cross-Functional Scrum-Teams in a Hardware ProjectStephanie Gasche
 
Why Limit WIP?
Why Limit WIP?  Why Limit WIP?
Why Limit WIP? LeanKit
 
DevOps in Action: How Nedbank went from quarterly to weekly releases in no ti...
DevOps in Action: How Nedbank went from quarterly to weekly releases in no ti...DevOps in Action: How Nedbank went from quarterly to weekly releases in no ti...
DevOps in Action: How Nedbank went from quarterly to weekly releases in no ti...Agile Software Community of India
 
Improving the Quality of Incoming Code
Improving the Quality of Incoming CodeImproving the Quality of Incoming Code
Improving the Quality of Incoming CodeNaresh Jain
 
Andrii Prosov - RACI Matrix as an instrument for communication with a client
Andrii Prosov - RACI Matrix as an instrument for communication with a clientAndrii Prosov - RACI Matrix as an instrument for communication with a client
Andrii Prosov - RACI Matrix as an instrument for communication with a clientLviv Startup Club
 

Was ist angesagt? (20)

Practical way to experience of Specification by Example
Practical way to experience of Specification by ExamplePractical way to experience of Specification by Example
Practical way to experience of Specification by Example
 
Agile testingandautomation
Agile testingandautomationAgile testingandautomation
Agile testingandautomation
 
Specification by Example - Agile India 2015
Specification by Example - Agile India 2015Specification by Example - Agile India 2015
Specification by Example - Agile India 2015
 
Developer Testing
Developer TestingDeveloper Testing
Developer Testing
 
How testers add value to the organization appium conf
How testers add value to the organization  appium confHow testers add value to the organization  appium conf
How testers add value to the organization appium conf
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Unit testing for project managers
Unit testing for project managersUnit testing for project managers
Unit testing for project managers
 
Behavior driven development - cucumber, Junit and java
Behavior driven development - cucumber, Junit and javaBehavior driven development - cucumber, Junit and java
Behavior driven development - cucumber, Junit and java
 
ALE15 The real value of a definition of done
ALE15  The real value of a definition of doneALE15  The real value of a definition of done
ALE15 The real value of a definition of done
 
Identifying and measuring testing debt
Identifying and measuring testing debtIdentifying and measuring testing debt
Identifying and measuring testing debt
 
Test Driven Development – how it benefits business and teams alike
Test Driven Development – how it benefits business and teams alikeTest Driven Development – how it benefits business and teams alike
Test Driven Development – how it benefits business and teams alike
 
Desire2Learn Conversion Labs: Fishing for Early Adopters
Desire2Learn Conversion Labs: Fishing for Early AdoptersDesire2Learn Conversion Labs: Fishing for Early Adopters
Desire2Learn Conversion Labs: Fishing for Early Adopters
 
Test Automation Pyramid
Test Automation PyramidTest Automation Pyramid
Test Automation Pyramid
 
Reduce WIP and Deliver Often: Kanban Recipe for Success Steps 2 and 3
Reduce WIP and Deliver Often: Kanban Recipe for Success Steps 2 and 3Reduce WIP and Deliver Often: Kanban Recipe for Success Steps 2 and 3
Reduce WIP and Deliver Often: Kanban Recipe for Success Steps 2 and 3
 
Session on Look beyond what the eyes can see- Reviving Visual validations by ...
Session on Look beyond what the eyes can see- Reviving Visual validations by ...Session on Look beyond what the eyes can see- Reviving Visual validations by ...
Session on Look beyond what the eyes can see- Reviving Visual validations by ...
 
Building Cross-Functional Scrum-Teams in a Hardware Project
Building Cross-Functional Scrum-Teams in a Hardware ProjectBuilding Cross-Functional Scrum-Teams in a Hardware Project
Building Cross-Functional Scrum-Teams in a Hardware Project
 
Why Limit WIP?
Why Limit WIP?  Why Limit WIP?
Why Limit WIP?
 
DevOps in Action: How Nedbank went from quarterly to weekly releases in no ti...
DevOps in Action: How Nedbank went from quarterly to weekly releases in no ti...DevOps in Action: How Nedbank went from quarterly to weekly releases in no ti...
DevOps in Action: How Nedbank went from quarterly to weekly releases in no ti...
 
Improving the Quality of Incoming Code
Improving the Quality of Incoming CodeImproving the Quality of Incoming Code
Improving the Quality of Incoming Code
 
Andrii Prosov - RACI Matrix as an instrument for communication with a client
Andrii Prosov - RACI Matrix as an instrument for communication with a clientAndrii Prosov - RACI Matrix as an instrument for communication with a client
Andrii Prosov - RACI Matrix as an instrument for communication with a client
 

Ähnlich wie The Future of Testing Magento 2 Modules with TDD and BDD

Test driven development
Test driven developmentTest driven development
Test driven developmentSunil Prasad
 
Effective Testing Practices in an Agile Environment
Effective Testing Practices in an Agile EnvironmentEffective Testing Practices in an Agile Environment
Effective Testing Practices in an Agile EnvironmentRaj Indugula
 
Developer Productivity Engineering with Gradle
Developer Productivity Engineering with GradleDeveloper Productivity Engineering with Gradle
Developer Productivity Engineering with GradleAll Things Open
 
Productive and Cost Effective Development Feedback Loops Within Continuous De...
Productive and Cost Effective Development Feedback Loops Within Continuous De...Productive and Cost Effective Development Feedback Loops Within Continuous De...
Productive and Cost Effective Development Feedback Loops Within Continuous De...Brian Mericle
 
How BiggerPockets runs experiments faster with performance edge
How BiggerPockets runs experiments faster with performance edgeHow BiggerPockets runs experiments faster with performance edge
How BiggerPockets runs experiments faster with performance edgeOptimizely
 
How BDD enables True CI/CD
How BDD enables True CI/CDHow BDD enables True CI/CD
How BDD enables True CI/CDRoger Turnau
 
Webinar agile-spring-maximum-roi
Webinar agile-spring-maximum-roiWebinar agile-spring-maximum-roi
Webinar agile-spring-maximum-roiCygnet Infotech
 
Assessing Your Agility: Introducing the Comparative Agility Assessment
Assessing Your Agility: Introducing the Comparative Agility AssessmentAssessing Your Agility: Introducing the Comparative Agility Assessment
Assessing Your Agility: Introducing the Comparative Agility AssessmentMike Cohn
 
Approval Tests in Action: A LEGO Exercise and an Experience Report
Approval Tests in Action: A LEGO Exercise and an Experience ReportApproval Tests in Action: A LEGO Exercise and an Experience Report
Approval Tests in Action: A LEGO Exercise and an Experience Reporthouseofyin
 
QA Role In Agile Teams - by Michael Hall
QA Role In Agile Teams - by Michael HallQA Role In Agile Teams - by Michael Hall
QA Role In Agile Teams - by Michael HallSynerzip
 
Scrum Bangalore 13th meet up 13 june 2015 - behaviour driven development - vi...
Scrum Bangalore 13th meet up 13 june 2015 - behaviour driven development - vi...Scrum Bangalore 13th meet up 13 june 2015 - behaviour driven development - vi...
Scrum Bangalore 13th meet up 13 june 2015 - behaviour driven development - vi...Scrum Bangalore
 
Introduction to Continuous Delivery (BBWorld/DevCon 2013)
Introduction to Continuous Delivery (BBWorld/DevCon 2013)Introduction to Continuous Delivery (BBWorld/DevCon 2013)
Introduction to Continuous Delivery (BBWorld/DevCon 2013)Mike McGarr
 
Bugday bkk-2014 nitisak-auto_perf
Bugday bkk-2014 nitisak-auto_perfBugday bkk-2014 nitisak-auto_perf
Bugday bkk-2014 nitisak-auto_perfNitisak Mooltreesri
 
User Stories from Scenarios
User Stories from ScenariosUser Stories from Scenarios
User Stories from ScenariosRavikanth-BA
 
Mastering BDD - Eran Kinsbruner Workshop Quest 2018
Mastering BDD - Eran Kinsbruner Workshop Quest 2018Mastering BDD - Eran Kinsbruner Workshop Quest 2018
Mastering BDD - Eran Kinsbruner Workshop Quest 2018Perfecto Mobile
 
Guerilla Usability Testing
Guerilla Usability TestingGuerilla Usability Testing
Guerilla Usability TestingAndy Budd
 
Behavior Driven Development—A Guide to Agile Practices by Josh Eastman
Behavior Driven Development—A Guide to Agile Practices by Josh EastmanBehavior Driven Development—A Guide to Agile Practices by Josh Eastman
Behavior Driven Development—A Guide to Agile Practices by Josh EastmanQA or the Highway
 
Advanced automated visual testing at DrupalCon Europe 2020
Advanced automated visual testing at DrupalCon Europe 2020Advanced automated visual testing at DrupalCon Europe 2020
Advanced automated visual testing at DrupalCon Europe 2020Shweta Sharma
 
Technology-Driven Development: Using Automation and Development Techniques to...
Technology-Driven Development: Using Automation and Development Techniques to...Technology-Driven Development: Using Automation and Development Techniques to...
Technology-Driven Development: Using Automation and Development Techniques to...Rakuten Group, Inc.
 

Ähnlich wie The Future of Testing Magento 2 Modules with TDD and BDD (20)

Test driven development
Test driven developmentTest driven development
Test driven development
 
Effective Testing Practices in an Agile Environment
Effective Testing Practices in an Agile EnvironmentEffective Testing Practices in an Agile Environment
Effective Testing Practices in an Agile Environment
 
Developer Productivity Engineering with Gradle
Developer Productivity Engineering with GradleDeveloper Productivity Engineering with Gradle
Developer Productivity Engineering with Gradle
 
Productive and Cost Effective Development Feedback Loops Within Continuous De...
Productive and Cost Effective Development Feedback Loops Within Continuous De...Productive and Cost Effective Development Feedback Loops Within Continuous De...
Productive and Cost Effective Development Feedback Loops Within Continuous De...
 
Why becoming agile is hard, but worth it
Why becoming agile is hard, but worth itWhy becoming agile is hard, but worth it
Why becoming agile is hard, but worth it
 
How BiggerPockets runs experiments faster with performance edge
How BiggerPockets runs experiments faster with performance edgeHow BiggerPockets runs experiments faster with performance edge
How BiggerPockets runs experiments faster with performance edge
 
How BDD enables True CI/CD
How BDD enables True CI/CDHow BDD enables True CI/CD
How BDD enables True CI/CD
 
Webinar agile-spring-maximum-roi
Webinar agile-spring-maximum-roiWebinar agile-spring-maximum-roi
Webinar agile-spring-maximum-roi
 
Assessing Your Agility: Introducing the Comparative Agility Assessment
Assessing Your Agility: Introducing the Comparative Agility AssessmentAssessing Your Agility: Introducing the Comparative Agility Assessment
Assessing Your Agility: Introducing the Comparative Agility Assessment
 
Approval Tests in Action: A LEGO Exercise and an Experience Report
Approval Tests in Action: A LEGO Exercise and an Experience ReportApproval Tests in Action: A LEGO Exercise and an Experience Report
Approval Tests in Action: A LEGO Exercise and an Experience Report
 
QA Role In Agile Teams - by Michael Hall
QA Role In Agile Teams - by Michael HallQA Role In Agile Teams - by Michael Hall
QA Role In Agile Teams - by Michael Hall
 
Scrum Bangalore 13th meet up 13 june 2015 - behaviour driven development - vi...
Scrum Bangalore 13th meet up 13 june 2015 - behaviour driven development - vi...Scrum Bangalore 13th meet up 13 june 2015 - behaviour driven development - vi...
Scrum Bangalore 13th meet up 13 june 2015 - behaviour driven development - vi...
 
Introduction to Continuous Delivery (BBWorld/DevCon 2013)
Introduction to Continuous Delivery (BBWorld/DevCon 2013)Introduction to Continuous Delivery (BBWorld/DevCon 2013)
Introduction to Continuous Delivery (BBWorld/DevCon 2013)
 
Bugday bkk-2014 nitisak-auto_perf
Bugday bkk-2014 nitisak-auto_perfBugday bkk-2014 nitisak-auto_perf
Bugday bkk-2014 nitisak-auto_perf
 
User Stories from Scenarios
User Stories from ScenariosUser Stories from Scenarios
User Stories from Scenarios
 
Mastering BDD - Eran Kinsbruner Workshop Quest 2018
Mastering BDD - Eran Kinsbruner Workshop Quest 2018Mastering BDD - Eran Kinsbruner Workshop Quest 2018
Mastering BDD - Eran Kinsbruner Workshop Quest 2018
 
Guerilla Usability Testing
Guerilla Usability TestingGuerilla Usability Testing
Guerilla Usability Testing
 
Behavior Driven Development—A Guide to Agile Practices by Josh Eastman
Behavior Driven Development—A Guide to Agile Practices by Josh EastmanBehavior Driven Development—A Guide to Agile Practices by Josh Eastman
Behavior Driven Development—A Guide to Agile Practices by Josh Eastman
 
Advanced automated visual testing at DrupalCon Europe 2020
Advanced automated visual testing at DrupalCon Europe 2020Advanced automated visual testing at DrupalCon Europe 2020
Advanced automated visual testing at DrupalCon Europe 2020
 
Technology-Driven Development: Using Automation and Development Techniques to...
Technology-Driven Development: Using Automation and Development Techniques to...Technology-Driven Development: Using Automation and Development Techniques to...
Technology-Driven Development: Using Automation and Development Techniques to...
 

Kürzlich hochgeladen

MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
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
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
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
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentationvaddepallysandeep122
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
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
 
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
 
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
 
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
 
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
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
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
 

Kürzlich hochgeladen (20)

MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
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
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
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
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
 
Odoo Development Company in India | Devintelle Consulting Service
Odoo Development Company in India | Devintelle Consulting ServiceOdoo Development Company in India | Devintelle Consulting Service
Odoo Development Company in India | Devintelle Consulting Service
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
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
 
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
 
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
 
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)
 
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...
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
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...
 

The Future of Testing Magento 2 Modules with TDD and BDD

  • 1. Page | 1 Where have we been and what do we do? The Future of Testing Magento 2
  • 2. Page | 2 About Me James Cowie ● CTO @ Shero Commerce ● Magento Master ● BDD / TDD advocate ● @jcowie ● @sherocommerce
  • 3. Page | 3Page | 3 ➔ “The process of learning effective TDD is the process of learning how to build more modular applications.” The Goal
  • 4. Page | 4Page | 4 ➔ “The process of learning effective TDD is the process of learning how to build more modular applications.” The Goal
  • 5. Page | 5 The Reasons to not test ➔ We don't have the budget! ➔ We don’t have the time! ➔ Testing slows us down! ➔ We don’t have the training! ➔ It gets in the way! ➔ The client won’t pay for it! ➔ The tests become out of date ➔ They run slow and hold us back! ➔ Ship first test later
  • 6. Page | 6 Group the historical reasons Time Knowledge Understanding Testing slows us down! We don’t have the training! Ship first test later We don’t have the time! The tests become out of date They run slow and hold us back! We don't have the budget! Ship first test later The client won’t pay for it!
  • 7. Page | 7Page | 7 Time
  • 8. Page | 8 Time to add features over time without tests ● Faster to start with ● Slows down due to large code ● More time spent manual testing ● Higher chance of defects
  • 9. Page | 9 Time to add features over time with tests ● Does add time initially ● Get faster for feature development ● Less chance of defects ● Better use of time on exploratory testing ● More maintainable
  • 10. Page | 10 Time Conclusion Testing slows us down Over time testing speeds you up. We don’t have time Having tests will shorten delivery time making more time. The client won’t pay for it Clients don’t need to know how you cook the steak. Instead, they will pay for excellence and high quality.
  • 11. Page | 11Page | 11 Knowledge
  • 12. Page | 12 Knowledge. The hard truth ➔ Testing is _hard_ ➔ Architecture can hinder ➔ Complete mind shift ➔ Is a whole team sport
  • 13. Page | 13 Knowledge. Current design
  • 14. Page | 14 Knowledge. Current design
  • 15. Page | 15 Has this been solved before? ➔ Ports and Adaptors ➔ Hexagonal Architecture ➔ DDD Alistair, Cockburn (2005-04-01). "Hexagonal architecture". alistair.cockburn.us.
  • 16. Page | 16 Knowledge. Future design
  • 17. Page | 17 Knowledge. Future design Adaptor Port
  • 18. Page | 18 Ports ➔ Slim Magento 2 module ➔ Contains no business logic ➔ Traditional Magento 2 module
  • 19. Page | 19 Adaptors ➔ The custom implementation, ➔ Business logic ➔ Dependency inverted, ➔ Injectable
  • 20. Page | 20 The Bridge ➔ Can be an API ➔ Dependency Injection into slim Magento 2 client ➔ Responsible for linking the 2 systems
  • 21. Page | 21Page | 21 Types of testing
  • 22. Page | 22 Types of testing ➔ Unit Testing ➔ Integration Testing ➔ Acceptance Testing
  • 23. Page | 23 Unit Testing ➔ Internal testing (Inwards)
  • 24. Page | 24 Integration Testing ➔ Outside facing testing (outwards)
  • 25. Page | 25 Acceptance Testing ➔ Does it work?
  • 26. Page | 26 What tools are available?
  • 27. Page | 27 Pick the right tool for your team ➔ Not all tools are equal, ➔ Varying levels of effort and knowledge, ➔ Used in different scenarios.
  • 28. Page | 28 Behaviour Driven Development (BDD)
  • 29. Page | 29 More traditional TDD
  • 30. Page | 30 What hinders testing? ➔ Inheritance ➔ Tight Coupling ➔ Testing after concrete code is wrote
  • 31. Page | 31 Favour Composition • Blueprints to the concrete implementation • Describe functionality.
  • 32. Page | 32Page | 32 TDD workflow
  • 33. Page | 33 The TDD dance
  • 34. Page | 34 The TDD dance Write a failing test
  • 35. Page | 35 The TDD dance Write just enough code to make the test pass
  • 36. Page | 36 The TDD dance Refactor the code to be complete
  • 37. Page | 37 Think design / architecture ➔ Your only thinking about small units, ➔ Refactoring is safe, ➔ Your designing with interfaces, ➔ Stops gold plating.
  • 38. Page | 38Page | 38 • This is a simple module but should highlight how simple setup can be. Lets see this in practice
  • 39. Page | 39 The module / Demo PayMate LTD provides the ability to part pay for goods and split it over a number of months. They handle the payment side of the process but they need the product details page to show the split. The business rules are: • Products under $50 can be split into 2 monthly payments • Products under $200 can be split into 4 monthly payments • Products over $500 can NOT be split
  • 40. Page | 40 Code Structure
  • 42. Page | 42 Failing Testing Fail
  • 43. Page | 43 Failing Testing Fail
  • 44. Page | 44 Failing Testing Fail
  • 45. Page | 45 Make it green (small increment) Pass
  • 46. Page | 46 Make it green (small increment) Pass
  • 47. Page | 47 Failing Testing Fail
  • 48. Page | 48 Failing Testing Fail
  • 49. Page | 49 Write just enough code to make it pass Pass
  • 50. Page | 50 Failing Testing Fail
  • 51. Page | 51 Failing Testing Fail
  • 52. Page | 52 Write just enough code to make it pass Pass
  • 54. Page | 54 Using the mock to get price
  • 55. Page | 55 v Disclaimer The way I use the registry is NOT complete and also bad practice.
  • 56. Page | 56 Make it do something
  • 61. Page | 61 Integration testing ➔ Mink offers helpers ➔ Use a Magento driver
  • 62. Page | 62 Refactoring Step ➔ Now that the tests pass Refactor! ➔ Remove the hard values for dynamic ➔ Keep running the tests
  • 63. Page | 63 Integration testing ➔ Behat runs via Selenium ➔ The feature context is the powerhouse ➔ Its slower than Unit tests ➔ Can be optimized via Behat plugins
  • 64. Page | 64 v Overview of our testing PHPUnit Behat Core Domain
  • 65. Page | 65 Where to go from here? ➔ To team code katas ➔ Keep practicing ➔ Watch Vinai’s kata series ➔ Watch out for Fabian Schmengler book