SlideShare a Scribd company logo
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

The Road to QA
The Road to QAThe Road to QA
The Road to QA
Benjamin Bischoff
 
Agile Workshop for Teams
Agile Workshop for TeamsAgile Workshop for Teams
Agile Workshop for Teams
TroyAnderson54
 
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 2017
Chad 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 Summit
Amazon 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 Concerns
Gokul 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 driving
Juntima 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 Summit
Amazon 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 #LRM
Gunnar 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 DevOps
Giulio 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_texto
Rosa Cano
 
Pair Programming
Pair ProgrammingPair Programming
Pair Programming
Carlos Corrêa da Silva
 
Pintrace: Distributed tracing@Pinterest
Pintrace: Distributed tracing@PinterestPintrace: Distributed tracing@Pinterest
Pintrace: Distributed tracing@Pinterest
Suman Karumuri
 
eHarmony @ Phoenix Con 2016
eHarmony @ Phoenix Con 2016eHarmony @ Phoenix Con 2016
eHarmony @ Phoenix Con 2016
Vijaykumar Vangapandu
 
Reducing Resistance: Deployment as Surface
Reducing Resistance: Deployment as SurfaceReducing Resistance: Deployment as Surface
Reducing Resistance: Deployment as Surface
Jeffrey 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 Summit
Amazon Web Services
 
Semantic BDD with ShouldIT?
Semantic BDD with ShouldIT?Semantic BDD with ShouldIT?
Semantic BDD with ShouldIT?
Richard McIntyre
 
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
DigiMarCon - Digital Marketing, Media and Advertising Conferences & Exhibitions
 

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 Wizeline
DevDay.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 Wizeline
DevDay.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 KMS
DevDay.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 IO
DevDay.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

RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
Rohit Gautam
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 

Recently uploaded (20)

RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 

[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