SlideShare a Scribd company logo
1 of 27
U N I T T E S T I N G I N P H P A N D
L A R A V E L F R A M E W O R K
‣ LE MAI VIEN
‣ 28 years old
‣ Asian Tech Inc.
‣ Technical Leader
‣ Backend developer
‣ 5 years of experiences
A B O U T M E
W H A T I S H I G H Q U A L I T Y
C O D E ? ? ?
I T ’ S
G O O D ? ? ?
W H A T I S H I G H Q U A L I T Y
C O D E ? ? ?
S E L F E XP L A I N I N G D O C U M E N T A T I O N
C L E A R - R E A D A B L E
A R C H I T E C T U R E D E S I G N
D E S I G N P A T T E R N
T E S T C O D E
E A S E O F
E XT E N S I B I L I T Y
‣ Test by human
‣ Create test cases
‣ Repeat many times
‣ Difficult to check affection
‣ Take a lot of time and efforts
M A N U A L T E S T I N G
W H A T D O D E V E L O P E R S D O W H E N
T H E Y I M P L E M E N T
C O D E T E S T
Switch
Y O U A L R E A D Y T E S T Y O U R
C O D E
S U B M I T A F O R M , C H E C K D B
C O N S O L E . L O G ( )
D U M P V A R I A B L E S
L O G T O F I L E
C H R O M E D E B U G T O O L
…
W R I T E C O D E T O T E S T Y O U R
C O D E
‣ Check code by code
‣ Can reuse many time
‣ There are many kinds of
test code
W H Y N O T ?
T E S T I N G M E T H O D S
‣ Unit testing
‣ Integration testing
‣ Functional testing
‣ Acceptance testing
‣ E2E testing
W H Y D E V E L O P E R H A V E T O W R I T E
C O D E T O T E S T T H E I R C O D E
‣ Quality of code
‣ Find bugs early
‣ Facilitates changes simplifies integration
‣ Provide document
‣ Debugging process
‣ Design
‣ Reduce cost
U N I T T E S T I N G
‣ Test a smallest piece of testable code
‣ Check the Code is working as expected
‣ Testing in isolation
‣ Tests should not be order-dependent
U N I T T E S T I N G
Unit tests
Production code
3 steps of a Unit test
1. Arrange
2. Act
3. Assert
1 0 0 1 R E A S O N S T O S K I P U N I T
T E S T
‣ I don’t have time
‣ Deadline is too short
‣ I don’t know how to do
‣ Client doesn’t want to write UT
‣ …
A L L J U S T E X C U S E , L E T W R I T E U N I T T E S T
U N I T T E S T I S I M P O R T A N T , I S N ’ T
I T ?
C O D E C O V E R A G E
T e s t e d
T e s t e d
C r e a t e m o c k
o b j e c t
M O C K E R Y
ple yet flexible PHP mock object framework for use in unit te
S E T E X P E C T A T I O N S T O M O C K
O B J E C T
T h i s m e t h o d
m u s t b e c a l l e d
e x a c t l y 1 t i m e
Mock vs Stub
Setup
Exercise
Verify state
Teardown
Setup data
Setup Expectations
Exercise
Verify expectations
Verify state
Teardown
U N I T T E S T I N G
‣ Test a smallest piece of code
‣ Testing in isolation
‣ Code coverage
‣ Stub and mock
H O W A B O U T
L A R A V E L ?
I t ’ s n o t u n i t t e s t i n g
I t ’ s f u n c t i o n a l t e s t i n g
L A R A V E L H T T P T E S T
L A R A V E L T E S T J S O N A P I
S U M M A R Y
‣ Manual test
‣ Benefit of writing code to test your code
‣ Phpunit
‣ Unit testing
‣ Code coverage
‣ Another testing methods
T H A N K Y O U F O R L I S T E N I N G
http://asiantech.vn/en/careers

More Related Content

Similar to [DevDay2018] Unit testing in PHP and Laravel Framework - Unit testing in PHP and Laravel Framework

Agile Workshop for Teams
Agile Workshop for TeamsAgile Workshop for Teams
Agile Workshop for TeamsTroyAnderson54
 
TDD Using the SOLID Principles
TDD Using the SOLID PrinciplesTDD Using the SOLID Principles
TDD Using the SOLID PrinciplesJenna Pederson
 
Managing Technical Debt - WordCamp Orlando 2017
Managing Technical Debt - WordCamp Orlando 2017Managing Technical Debt - WordCamp Orlando 2017
Managing Technical Debt - WordCamp Orlando 2017Chad Windnagle
 
Gain Maximum Visibility - DEM06 - Anaheim AWS Summit
Gain Maximum Visibility - DEM06 - Anaheim AWS SummitGain Maximum Visibility - DEM06 - Anaheim AWS Summit
Gain Maximum Visibility - DEM06 - Anaheim AWS SummitAmazon Web Services
 
Blockchain Technology : Privacy Perspectives and Security Concerns
Blockchain Technology : Privacy Perspectives and Security ConcernsBlockchain Technology : Privacy Perspectives and Security Concerns
Blockchain Technology : Privacy Perspectives and Security ConcernsGokul Alex
 
Touch Drive - A touch-based multi-function controller for autonomous driving
Touch Drive - A touch-based multi-function controller for autonomous drivingTouch Drive - A touch-based multi-function controller for autonomous driving
Touch Drive - A touch-based multi-function controller for autonomous drivingJuntima Nawilaijaroen
 
Gain Maximum Visibility into Your Applications - DEM04 - Atlanta AWS Summit
Gain Maximum Visibility into Your Applications - DEM04 - Atlanta AWS SummitGain Maximum Visibility into Your Applications - DEM04 - Atlanta AWS Summit
Gain Maximum Visibility into Your Applications - DEM04 - Atlanta AWS SummitAmazon Web Services
 
Competency-Based Learning and Learning Relationship Management #LRM
Competency-Based Learning and Learning Relationship Management #LRMCompetency-Based Learning and Learning Relationship Management #LRM
Competency-Based Learning and Learning Relationship Management #LRMGunnar Counselman
 
Construir productos y transformación digital mezclando tecnología y educación...
Construir productos y transformación digital mezclando tecnología y educación...Construir productos y transformación digital mezclando tecnología y educación...
Construir productos y transformación digital mezclando tecnología y educación...Rosa Cano
 
Pipeline your Pipelines - 2020 All Day DevOps
Pipeline your Pipelines - 2020 All Day DevOpsPipeline your Pipelines - 2020 All Day DevOps
Pipeline your Pipelines - 2020 All Day DevOpsGiulio Vian
 
Sopa de letras y crucigrama
Sopa de letras y crucigramaSopa de letras y crucigrama
Sopa de letras y crucigramamalatest
 
Rosa Cano_openexpo2018_sin_texto
Rosa Cano_openexpo2018_sin_textoRosa Cano_openexpo2018_sin_texto
Rosa Cano_openexpo2018_sin_textoRosa Cano
 
Pintrace: Distributed tracing@Pinterest
Pintrace: Distributed tracing@PinterestPintrace: Distributed tracing@Pinterest
Pintrace: Distributed tracing@PinterestSuman Karumuri
 
Reducing Resistance: Deployment as Surface
Reducing Resistance: Deployment as SurfaceReducing Resistance: Deployment as Surface
Reducing Resistance: Deployment as SurfaceJeffrey Hulten
 
Gain Maximum Visibility - DEM05 - Toronto AWS Summit
Gain Maximum Visibility - DEM05 - Toronto AWS SummitGain Maximum Visibility - DEM05 - Toronto AWS Summit
Gain Maximum Visibility - DEM05 - Toronto AWS SummitAmazon Web Services
 
Semantic BDD with ShouldIT?
Semantic BDD with ShouldIT?Semantic BDD with ShouldIT?
Semantic BDD with ShouldIT?Richard McIntyre
 

Similar to [DevDay2018] Unit testing in PHP and Laravel Framework - Unit testing in PHP and Laravel Framework (20)

The Road to QA
The Road to QAThe Road to QA
The Road to QA
 
Agile Workshop for Teams
Agile Workshop for TeamsAgile Workshop for Teams
Agile Workshop for Teams
 
TDD Using the SOLID Principles
TDD Using the SOLID PrinciplesTDD Using the SOLID Principles
TDD Using the SOLID Principles
 
Managing Technical Debt - WordCamp Orlando 2017
Managing Technical Debt - WordCamp Orlando 2017Managing Technical Debt - WordCamp Orlando 2017
Managing Technical Debt - WordCamp Orlando 2017
 
Gain Maximum Visibility - DEM06 - Anaheim AWS Summit
Gain Maximum Visibility - DEM06 - Anaheim AWS SummitGain Maximum Visibility - DEM06 - Anaheim AWS Summit
Gain Maximum Visibility - DEM06 - Anaheim AWS Summit
 
Blockchain Technology : Privacy Perspectives and Security Concerns
Blockchain Technology : Privacy Perspectives and Security ConcernsBlockchain Technology : Privacy Perspectives and Security Concerns
Blockchain Technology : Privacy Perspectives and Security Concerns
 
Touch Drive - A touch-based multi-function controller for autonomous driving
Touch Drive - A touch-based multi-function controller for autonomous drivingTouch Drive - A touch-based multi-function controller for autonomous driving
Touch Drive - A touch-based multi-function controller for autonomous driving
 
Gain Maximum Visibility into Your Applications - DEM04 - Atlanta AWS Summit
Gain Maximum Visibility into Your Applications - DEM04 - Atlanta AWS SummitGain Maximum Visibility into Your Applications - DEM04 - Atlanta AWS Summit
Gain Maximum Visibility into Your Applications - DEM04 - Atlanta AWS Summit
 
Competency-Based Learning and Learning Relationship Management #LRM
Competency-Based Learning and Learning Relationship Management #LRMCompetency-Based Learning and Learning Relationship Management #LRM
Competency-Based Learning and Learning Relationship Management #LRM
 
Construir productos y transformación digital mezclando tecnología y educación...
Construir productos y transformación digital mezclando tecnología y educación...Construir productos y transformación digital mezclando tecnología y educación...
Construir productos y transformación digital mezclando tecnología y educación...
 
Pipeline your Pipelines - 2020 All Day DevOps
Pipeline your Pipelines - 2020 All Day DevOpsPipeline your Pipelines - 2020 All Day DevOps
Pipeline your Pipelines - 2020 All Day DevOps
 
Sopa de letras y crucigrama
Sopa de letras y crucigramaSopa de letras y crucigrama
Sopa de letras y crucigrama
 
Rosa Cano_openexpo2018_sin_texto
Rosa Cano_openexpo2018_sin_textoRosa Cano_openexpo2018_sin_texto
Rosa Cano_openexpo2018_sin_texto
 
Pair Programming
Pair ProgrammingPair Programming
Pair Programming
 
Pintrace: Distributed tracing@Pinterest
Pintrace: Distributed tracing@PinterestPintrace: Distributed tracing@Pinterest
Pintrace: Distributed tracing@Pinterest
 
eHarmony @ Phoenix Con 2016
eHarmony @ Phoenix Con 2016eHarmony @ Phoenix Con 2016
eHarmony @ Phoenix Con 2016
 
Reducing Resistance: Deployment as Surface
Reducing Resistance: Deployment as SurfaceReducing Resistance: Deployment as Surface
Reducing Resistance: Deployment as Surface
 
Gain Maximum Visibility - DEM05 - Toronto AWS Summit
Gain Maximum Visibility - DEM05 - Toronto AWS SummitGain Maximum Visibility - DEM05 - Toronto AWS Summit
Gain Maximum Visibility - DEM05 - Toronto AWS Summit
 
Semantic BDD with ShouldIT?
Semantic BDD with ShouldIT?Semantic BDD with ShouldIT?
Semantic BDD with ShouldIT?
 
A ChatGPT Content Creation Master Class - Leah Faul, 15000 Cubits
A ChatGPT Content Creation Master Class - Leah Faul, 15000 CubitsA ChatGPT Content Creation Master Class - Leah Faul, 15000 Cubits
A ChatGPT Content Creation Master Class - Leah Faul, 15000 Cubits
 

More from DevDay.org

[DevDay2019] Lean UX - By Bryant Castro, Bryant Castro at Wizeline
[DevDay2019] Lean UX - By  Bryant Castro,  Bryant Castro at Wizeline[DevDay2019] Lean UX - By  Bryant Castro,  Bryant Castro at Wizeline
[DevDay2019] Lean UX - By Bryant Castro, Bryant Castro at WizelineDevDay.org
 
[DevDay2019] Why you'll lose without UX Design - By Szilard Toth, CTO at e·pi...
[DevDay2019] Why you'll lose without UX Design - By Szilard Toth, CTO at e·pi...[DevDay2019] Why you'll lose without UX Design - By Szilard Toth, CTO at e·pi...
[DevDay2019] Why you'll lose without UX Design - By Szilard Toth, CTO at e·pi...DevDay.org
 
[DevDay2019] Things i wish I knew when I was a 23-year-old Developer - By Chr...
[DevDay2019] Things i wish I knew when I was a 23-year-old Developer - By Chr...[DevDay2019] Things i wish I knew when I was a 23-year-old Developer - By Chr...
[DevDay2019] Things i wish I knew when I was a 23-year-old Developer - By Chr...DevDay.org
 
[DevDay2019] Designing design teams - Christopher Nguyen, UX Manager at Wizeline
[DevDay2019] Designing design teams - Christopher Nguyen, UX Manager at Wizeline[DevDay2019] Designing design teams - Christopher Nguyen, UX Manager at Wizeline
[DevDay2019] Designing design teams - Christopher Nguyen, UX Manager at WizelineDevDay.org
 
[DevDay2019] Growth Hacking - How to double the benefits of your startup with...
[DevDay2019] Growth Hacking - How to double the benefits of your startup with...[DevDay2019] Growth Hacking - How to double the benefits of your startup with...
[DevDay2019] Growth Hacking - How to double the benefits of your startup with...DevDay.org
 
[DevDay2019] Collaborate or die: The designers’ guide to working with develop...
[DevDay2019] Collaborate or die: The designers’ guide to working with develop...[DevDay2019] Collaborate or die: The designers’ guide to working with develop...
[DevDay2019] Collaborate or die: The designers’ guide to working with develop...DevDay.org
 
[DevDay2019] How AI is changing the future of Software Testing? - By Vui Nguy...
[DevDay2019] How AI is changing the future of Software Testing? - By Vui Nguy...[DevDay2019] How AI is changing the future of Software Testing? - By Vui Nguy...
[DevDay2019] How AI is changing the future of Software Testing? - By Vui Nguy...DevDay.org
 
[DevDay2019] Hands-on Machine Learning on Google Cloud Platform - By Thanh Le...
[DevDay2019] Hands-on Machine Learning on Google Cloud Platform - By Thanh Le...[DevDay2019] Hands-on Machine Learning on Google Cloud Platform - By Thanh Le...
[DevDay2019] Hands-on Machine Learning on Google Cloud Platform - By Thanh Le...DevDay.org
 
[DevDay2019] Micro Frontends Architecture - By Thang Pham, Senior Software En...
[DevDay2019] Micro Frontends Architecture - By Thang Pham, Senior Software En...[DevDay2019] Micro Frontends Architecture - By Thang Pham, Senior Software En...
[DevDay2019] Micro Frontends Architecture - By Thang Pham, Senior Software En...DevDay.org
 
[DevDay2019] Power of Test Automation and DevOps combination - One click savi...
[DevDay2019] Power of Test Automation and DevOps combination - One click savi...[DevDay2019] Power of Test Automation and DevOps combination - One click savi...
[DevDay2019] Power of Test Automation and DevOps combination - One click savi...DevDay.org
 
[DevDay2019] How do I test AI models? - By Minh Hoang, Senior QA Engineer at KMS
[DevDay2019] How do I test AI models? - By Minh Hoang, Senior QA Engineer at KMS[DevDay2019] How do I test AI models? - By Minh Hoang, Senior QA Engineer at KMS
[DevDay2019] How do I test AI models? - By Minh Hoang, Senior QA Engineer at KMSDevDay.org
 
[DevDay2019] How to quickly become a Senior Engineer - By Tran Anh Minh, CEO ...
[DevDay2019] How to quickly become a Senior Engineer - By Tran Anh Minh, CEO ...[DevDay2019] How to quickly become a Senior Engineer - By Tran Anh Minh, CEO ...
[DevDay2019] How to quickly become a Senior Engineer - By Tran Anh Minh, CEO ...DevDay.org
 
[Devday2019] Dev start-up - By Le Trung, Founder & CEO at Hifiveplus and Edu...
[Devday2019]  Dev start-up - By Le Trung, Founder & CEO at Hifiveplus and Edu...[Devday2019]  Dev start-up - By Le Trung, Founder & CEO at Hifiveplus and Edu...
[Devday2019] Dev start-up - By Le Trung, Founder & CEO at Hifiveplus and Edu...DevDay.org
 
[DevDay2019] Web Development In 2019 - A Practical Guide - By Hoang Nhu Vinh,...
[DevDay2019] Web Development In 2019 - A Practical Guide - By Hoang Nhu Vinh,...[DevDay2019] Web Development In 2019 - A Practical Guide - By Hoang Nhu Vinh,...
[DevDay2019] Web Development In 2019 - A Practical Guide - By Hoang Nhu Vinh,...DevDay.org
 
[DevDay2019] Opportunities and challenges for human resources during the digi...
[DevDay2019] Opportunities and challenges for human resources during the digi...[DevDay2019] Opportunities and challenges for human resources during the digi...
[DevDay2019] Opportunities and challenges for human resources during the digi...DevDay.org
 
[DevDay2019] Python Machine Learning with Jupyter Notebook - By Nguyen Huu Th...
[DevDay2019] Python Machine Learning with Jupyter Notebook - By Nguyen Huu Th...[DevDay2019] Python Machine Learning with Jupyter Notebook - By Nguyen Huu Th...
[DevDay2019] Python Machine Learning with Jupyter Notebook - By Nguyen Huu Th...DevDay.org
 
[DevDay2019] Do you dockerize? Are your containers safe? - By Pham Hong Khanh...
[DevDay2019] Do you dockerize? Are your containers safe? - By Pham Hong Khanh...[DevDay2019] Do you dockerize? Are your containers safe? - By Pham Hong Khanh...
[DevDay2019] Do you dockerize? Are your containers safe? - By Pham Hong Khanh...DevDay.org
 
[DevDay2019] Develop a web application with Kubernetes - By Nguyen Xuan Phong...
[DevDay2019] Develop a web application with Kubernetes - By Nguyen Xuan Phong...[DevDay2019] Develop a web application with Kubernetes - By Nguyen Xuan Phong...
[DevDay2019] Develop a web application with Kubernetes - By Nguyen Xuan Phong...DevDay.org
 
[DevDay2019] Paradigm shift towards effective Scrum - By Tam Doan, Agile Coac...
[DevDay2019] Paradigm shift towards effective Scrum - By Tam Doan, Agile Coac...[DevDay2019] Paradigm shift towards effective Scrum - By Tam Doan, Agile Coac...
[DevDay2019] Paradigm shift towards effective Scrum - By Tam Doan, Agile Coac...DevDay.org
 
[DevDay2019] JAM Stack - By Ngo Thi Ni, Web Developer at Agility IO
[DevDay2019] JAM Stack - By Ngo Thi Ni, Web Developer at Agility IO[DevDay2019] JAM Stack - By Ngo Thi Ni, Web Developer at Agility IO
[DevDay2019] JAM Stack - By Ngo Thi Ni, Web Developer at Agility IODevDay.org
 

More from DevDay.org (20)

[DevDay2019] Lean UX - By Bryant Castro, Bryant Castro at Wizeline
[DevDay2019] Lean UX - By  Bryant Castro,  Bryant Castro at Wizeline[DevDay2019] Lean UX - By  Bryant Castro,  Bryant Castro at Wizeline
[DevDay2019] Lean UX - By Bryant Castro, Bryant Castro at Wizeline
 
[DevDay2019] Why you'll lose without UX Design - By Szilard Toth, CTO at e·pi...
[DevDay2019] Why you'll lose without UX Design - By Szilard Toth, CTO at e·pi...[DevDay2019] Why you'll lose without UX Design - By Szilard Toth, CTO at e·pi...
[DevDay2019] Why you'll lose without UX Design - By Szilard Toth, CTO at e·pi...
 
[DevDay2019] Things i wish I knew when I was a 23-year-old Developer - By Chr...
[DevDay2019] Things i wish I knew when I was a 23-year-old Developer - By Chr...[DevDay2019] Things i wish I knew when I was a 23-year-old Developer - By Chr...
[DevDay2019] Things i wish I knew when I was a 23-year-old Developer - By Chr...
 
[DevDay2019] Designing design teams - Christopher Nguyen, UX Manager at Wizeline
[DevDay2019] Designing design teams - Christopher Nguyen, UX Manager at Wizeline[DevDay2019] Designing design teams - Christopher Nguyen, UX Manager at Wizeline
[DevDay2019] Designing design teams - Christopher Nguyen, UX Manager at Wizeline
 
[DevDay2019] Growth Hacking - How to double the benefits of your startup with...
[DevDay2019] Growth Hacking - How to double the benefits of your startup with...[DevDay2019] Growth Hacking - How to double the benefits of your startup with...
[DevDay2019] Growth Hacking - How to double the benefits of your startup with...
 
[DevDay2019] Collaborate or die: The designers’ guide to working with develop...
[DevDay2019] Collaborate or die: The designers’ guide to working with develop...[DevDay2019] Collaborate or die: The designers’ guide to working with develop...
[DevDay2019] Collaborate or die: The designers’ guide to working with develop...
 
[DevDay2019] How AI is changing the future of Software Testing? - By Vui Nguy...
[DevDay2019] How AI is changing the future of Software Testing? - By Vui Nguy...[DevDay2019] How AI is changing the future of Software Testing? - By Vui Nguy...
[DevDay2019] How AI is changing the future of Software Testing? - By Vui Nguy...
 
[DevDay2019] Hands-on Machine Learning on Google Cloud Platform - By Thanh Le...
[DevDay2019] Hands-on Machine Learning on Google Cloud Platform - By Thanh Le...[DevDay2019] Hands-on Machine Learning on Google Cloud Platform - By Thanh Le...
[DevDay2019] Hands-on Machine Learning on Google Cloud Platform - By Thanh Le...
 
[DevDay2019] Micro Frontends Architecture - By Thang Pham, Senior Software En...
[DevDay2019] Micro Frontends Architecture - By Thang Pham, Senior Software En...[DevDay2019] Micro Frontends Architecture - By Thang Pham, Senior Software En...
[DevDay2019] Micro Frontends Architecture - By Thang Pham, Senior Software En...
 
[DevDay2019] Power of Test Automation and DevOps combination - One click savi...
[DevDay2019] Power of Test Automation and DevOps combination - One click savi...[DevDay2019] Power of Test Automation and DevOps combination - One click savi...
[DevDay2019] Power of Test Automation and DevOps combination - One click savi...
 
[DevDay2019] How do I test AI models? - By Minh Hoang, Senior QA Engineer at KMS
[DevDay2019] How do I test AI models? - By Minh Hoang, Senior QA Engineer at KMS[DevDay2019] How do I test AI models? - By Minh Hoang, Senior QA Engineer at KMS
[DevDay2019] How do I test AI models? - By Minh Hoang, Senior QA Engineer at KMS
 
[DevDay2019] How to quickly become a Senior Engineer - By Tran Anh Minh, CEO ...
[DevDay2019] How to quickly become a Senior Engineer - By Tran Anh Minh, CEO ...[DevDay2019] How to quickly become a Senior Engineer - By Tran Anh Minh, CEO ...
[DevDay2019] How to quickly become a Senior Engineer - By Tran Anh Minh, CEO ...
 
[Devday2019] Dev start-up - By Le Trung, Founder & CEO at Hifiveplus and Edu...
[Devday2019]  Dev start-up - By Le Trung, Founder & CEO at Hifiveplus and Edu...[Devday2019]  Dev start-up - By Le Trung, Founder & CEO at Hifiveplus and Edu...
[Devday2019] Dev start-up - By Le Trung, Founder & CEO at Hifiveplus and Edu...
 
[DevDay2019] Web Development In 2019 - A Practical Guide - By Hoang Nhu Vinh,...
[DevDay2019] Web Development In 2019 - A Practical Guide - By Hoang Nhu Vinh,...[DevDay2019] Web Development In 2019 - A Practical Guide - By Hoang Nhu Vinh,...
[DevDay2019] Web Development In 2019 - A Practical Guide - By Hoang Nhu Vinh,...
 
[DevDay2019] Opportunities and challenges for human resources during the digi...
[DevDay2019] Opportunities and challenges for human resources during the digi...[DevDay2019] Opportunities and challenges for human resources during the digi...
[DevDay2019] Opportunities and challenges for human resources during the digi...
 
[DevDay2019] Python Machine Learning with Jupyter Notebook - By Nguyen Huu Th...
[DevDay2019] Python Machine Learning with Jupyter Notebook - By Nguyen Huu Th...[DevDay2019] Python Machine Learning with Jupyter Notebook - By Nguyen Huu Th...
[DevDay2019] Python Machine Learning with Jupyter Notebook - By Nguyen Huu Th...
 
[DevDay2019] Do you dockerize? Are your containers safe? - By Pham Hong Khanh...
[DevDay2019] Do you dockerize? Are your containers safe? - By Pham Hong Khanh...[DevDay2019] Do you dockerize? Are your containers safe? - By Pham Hong Khanh...
[DevDay2019] Do you dockerize? Are your containers safe? - By Pham Hong Khanh...
 
[DevDay2019] Develop a web application with Kubernetes - By Nguyen Xuan Phong...
[DevDay2019] Develop a web application with Kubernetes - By Nguyen Xuan Phong...[DevDay2019] Develop a web application with Kubernetes - By Nguyen Xuan Phong...
[DevDay2019] Develop a web application with Kubernetes - By Nguyen Xuan Phong...
 
[DevDay2019] Paradigm shift towards effective Scrum - By Tam Doan, Agile Coac...
[DevDay2019] Paradigm shift towards effective Scrum - By Tam Doan, Agile Coac...[DevDay2019] Paradigm shift towards effective Scrum - By Tam Doan, Agile Coac...
[DevDay2019] Paradigm shift towards effective Scrum - By Tam Doan, Agile Coac...
 
[DevDay2019] JAM Stack - By Ngo Thi Ni, Web Developer at Agility IO
[DevDay2019] JAM Stack - By Ngo Thi Ni, Web Developer at Agility IO[DevDay2019] JAM Stack - By Ngo Thi Ni, Web Developer at Agility IO
[DevDay2019] JAM Stack - By Ngo Thi Ni, Web Developer at Agility IO
 

Recently uploaded

Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfOverkill Security
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 

Recently uploaded (20)

Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 

[DevDay2018] Unit testing in PHP and Laravel Framework - Unit testing in PHP and Laravel Framework

  • 1. U N I T T E S T I N G I N P H P A N D L A R A V E L F R A M E W O R K
  • 2. ‣ LE MAI VIEN ‣ 28 years old ‣ Asian Tech Inc. ‣ Technical Leader ‣ Backend developer ‣ 5 years of experiences A B O U T M E
  • 3. W H A T I S H I G H Q U A L I T Y C O D E ? ? ? I T ’ S G O O D ? ? ?
  • 4. W H A T I S H I G H Q U A L I T Y C O D E ? ? ? S E L F E XP L A I N I N G D O C U M E N T A T I O N C L E A R - R E A D A B L E A R C H I T E C T U R E D E S I G N D E S I G N P A T T E R N T E S T C O D E E A S E O F E XT E N S I B I L I T Y
  • 5. ‣ Test by human ‣ Create test cases ‣ Repeat many times ‣ Difficult to check affection ‣ Take a lot of time and efforts M A N U A L T E S T I N G
  • 6. W H A T D O D E V E L O P E R S D O W H E N T H E Y I M P L E M E N T C O D E T E S T Switch
  • 7. Y O U A L R E A D Y T E S T Y O U R C O D E S U B M I T A F O R M , C H E C K D B C O N S O L E . L O G ( ) D U M P V A R I A B L E S L O G T O F I L E C H R O M E D E B U G T O O L …
  • 8. W R I T E C O D E T O T E S T Y O U R C O D E ‣ Check code by code ‣ Can reuse many time ‣ There are many kinds of test code W H Y N O T ?
  • 9. T E S T I N G M E T H O D S ‣ Unit testing ‣ Integration testing ‣ Functional testing ‣ Acceptance testing ‣ E2E testing
  • 10. W H Y D E V E L O P E R H A V E T O W R I T E C O D E T O T E S T T H E I R C O D E ‣ Quality of code ‣ Find bugs early ‣ Facilitates changes simplifies integration ‣ Provide document ‣ Debugging process ‣ Design ‣ Reduce cost
  • 11. U N I T T E S T I N G ‣ Test a smallest piece of testable code ‣ Check the Code is working as expected ‣ Testing in isolation ‣ Tests should not be order-dependent
  • 12. U N I T T E S T I N G Unit tests Production code
  • 13. 3 steps of a Unit test 1. Arrange 2. Act 3. Assert
  • 14. 1 0 0 1 R E A S O N S T O S K I P U N I T T E S T ‣ I don’t have time ‣ Deadline is too short ‣ I don’t know how to do ‣ Client doesn’t want to write UT ‣ … A L L J U S T E X C U S E , L E T W R I T E U N I T T E S T
  • 15. U N I T T E S T I S I M P O R T A N T , I S N ’ T I T ?
  • 16.
  • 17. C O D E C O V E R A G E
  • 18. T e s t e d T e s t e d
  • 19. C r e a t e m o c k o b j e c t M O C K E R Y ple yet flexible PHP mock object framework for use in unit te
  • 20. S E T E X P E C T A T I O N S T O M O C K O B J E C T T h i s m e t h o d m u s t b e c a l l e d e x a c t l y 1 t i m e
  • 21. Mock vs Stub Setup Exercise Verify state Teardown Setup data Setup Expectations Exercise Verify expectations Verify state Teardown
  • 22. U N I T T E S T I N G ‣ Test a smallest piece of code ‣ Testing in isolation ‣ Code coverage ‣ Stub and mock
  • 23. H O W A B O U T L A R A V E L ?
  • 24. I t ’ s n o t u n i t t e s t i n g I t ’ s f u n c t i o n a l t e s t i n g L A R A V E L H T T P T E S T
  • 25. L A R A V E L T E S T J S O N A P I
  • 26. S U M M A R Y ‣ Manual test ‣ Benefit of writing code to test your code ‣ Phpunit ‣ Unit testing ‣ Code coverage ‣ Another testing methods
  • 27. T H A N K Y O U F O R L I S T E N I N G http://asiantech.vn/en/careers