SlideShare a Scribd company logo
Getting started with
Testing
Adewale Andrade. 28/07/2017, Salvador, Bahia
WHY TEST?
○ Know that your code works…(and doesn’t
breaks anyone else’s).
○ Make deliveries and deploys more
stable….
○ Saves time (and pain) wasted on bug
fixing later…
○ Improving code designs and refactoring…
○ Reduce fear of failing...
TYPES OF TESTS (most common)
○ Unit Tests:
● Tests a small part of the application independently
from other parts; (Testing one class’s method);
○ Integration Test (Functional Tests):
● Tests different parts of the application working
together; (Testing a controller using multiple classes)
○ End-To-End Tests (E2E):
● Tests whether the flow of an application performs as
designed from start to finish; (Testing a login flow)
OUR STACK
○ PHPUnit
○ Neos Flow
○ PHP 5.5.9
○ Apache 2
OK… BUT…..
What are we really testing?
Test behaviour
Not implementation….
“When testing, face the code like a
complete stranger…
You have no idea how it does what
it should do…
But you know your expectations!
WHAT MAKES A GOOD UNIT TEST?
○ Unit tests should be:
● Easy to write;
● Easy to read;
● Fast;
● Not an integration test
■ No access to external resources (network,
databases, file systems, etc.)
A SIMPLE UNIT TEST
A SIMPLE INTEGRATION TEST
WHAT DO YOU NEED TO KNOW?
○ What are you testing?
○ How should it behave?
○ What are the edge cases?
○ Mapped entries?
○ Expected results?
OK… BUT…..
Does the code quality even
matter?
THINGS TO AVOID
As much as possible!
NON-DETERMINISTIC FACTORS
INTERNAL DEPENDENCIES
WHEN TO USE EACH ONE
○ Unit Tests:
● Models
● Services methods that don’t have internal
dependencies;
○ Integration Tests:
● Controllers;
● Services;
● Repositories;
HANDLING DEPENDENCIES
○ Unit tests:
● Maybe you should
refactor it….
● Dependency
Injection;
● Mocking;
● Maybe it is an
integration test;
https://jtreminio.com/2013/03/unit-testing-tutorial-part-4-mock-objects-stub-methods-depen
dency-injection/
HANDLING DEPENDENCIES
○ Integration tests:
● Dependency
Injection;
● Mocking;
● Do not mock
things that you
are testing.
Show me the
code!
Finally… some action!
REINFORCING THE CULTURE
○ Pull Requests + Code Review
○ Continuous Integration Servers
● Coverage Tests
● Build Breaking and Notifying
○ Leading by example
Thanks ;)
“With faith, my brother”
Adewale Andrade
Software Engineer
@Agilize Contabilidade Online
adewale.andrade@gmail.com

More Related Content

What's hot

Obejct Oriented SCM - OOSCM
Obejct Oriented SCM - OOSCMObejct Oriented SCM - OOSCM
Obejct Oriented SCM - OOSCM
Hernan Wilkinson
 
Mocking in python
Mocking in pythonMocking in python
Mocking in python
Ooblioob
 
Nguyenvandungb seminar
Nguyenvandungb seminarNguyenvandungb seminar
Nguyenvandungb seminar
dunglinh111
 
Testing And Drupal
Testing And DrupalTesting And Drupal
Testing And Drupal
Peter Arato
 
The art of being an agile programmer
The art of being an agile programmerThe art of being an agile programmer
The art of being an agile programmer
Claudia Rosu
 
Effective Unit Testing
Effective Unit TestingEffective Unit Testing
Effective Unit Testing
Eyal Kenig
 
Robot Framework Dos And Don'ts
Robot Framework Dos And Don'tsRobot Framework Dos And Don'ts
Robot Framework Dos And Don'ts
Pekka Klärck
 
What is stlc
What is stlcWhat is stlc
What is stlc
Abdullah Al Rumy
 
8 - Javascript unit testing framework
8 - Javascript unit testing framework8 - Javascript unit testing framework
8 - Javascript unit testing framework
Nguyen Duc Phu
 
Introduzione allo Unit Testing
Introduzione allo Unit TestingIntroduzione allo Unit Testing
Introduzione allo Unit Testing
Stefano Ottaviani
 
Practical pointers for better code review
Practical pointers for better code reviewPractical pointers for better code review
Practical pointers for better code review
khink
 
RoboCon 2018: How did we get here? Where do we go next?
RoboCon 2018: How did we get here? Where do we go next?RoboCon 2018: How did we get here? Where do we go next?
RoboCon 2018: How did we get here? Where do we go next?
Pekka Klärck
 
CLEAN CODE
CLEAN CODECLEAN CODE
CLEAN CODE
Knoldus Inc.
 
Android Frameworks: Highlighting the Need for a Solid Development Framework 
Android Frameworks: Highlighting the Need for a Solid Development Framework Android Frameworks: Highlighting the Need for a Solid Development Framework 
Android Frameworks: Highlighting the Need for a Solid Development Framework 
Mutual Mobile
 
DrTests: The Future of Testing in Pharo
DrTests: The Future of Testing in PharoDrTests: The Future of Testing in Pharo
DrTests: The Future of Testing in Pharo
ESUG
 
Technical screening .Net Developer
Technical screening  .Net DeveloperTechnical screening  .Net Developer
Technical screening .Net Developer
Tom Henricksen
 
TMPA-2015: The Application of Parameterized Hierarchy Templates for Automated...
TMPA-2015: The Application of Parameterized Hierarchy Templates for Automated...TMPA-2015: The Application of Parameterized Hierarchy Templates for Automated...
TMPA-2015: The Application of Parameterized Hierarchy Templates for Automated...
Iosif Itkin
 
Testing softvamp techno solutions technical interview questions for 1year exp...
Testing softvamp techno solutions technical interview questions for 1year exp...Testing softvamp techno solutions technical interview questions for 1year exp...
Testing softvamp techno solutions technical interview questions for 1year exp...
SoftvampTechnoSoluti
 
Effective Code Review
Effective Code ReviewEffective Code Review
Effective Code Review
Eyal Kenig
 
Specifications pattern
Specifications patternSpecifications pattern
Specifications pattern
Tung Nguyen
 

What's hot (20)

Obejct Oriented SCM - OOSCM
Obejct Oriented SCM - OOSCMObejct Oriented SCM - OOSCM
Obejct Oriented SCM - OOSCM
 
Mocking in python
Mocking in pythonMocking in python
Mocking in python
 
Nguyenvandungb seminar
Nguyenvandungb seminarNguyenvandungb seminar
Nguyenvandungb seminar
 
Testing And Drupal
Testing And DrupalTesting And Drupal
Testing And Drupal
 
The art of being an agile programmer
The art of being an agile programmerThe art of being an agile programmer
The art of being an agile programmer
 
Effective Unit Testing
Effective Unit TestingEffective Unit Testing
Effective Unit Testing
 
Robot Framework Dos And Don'ts
Robot Framework Dos And Don'tsRobot Framework Dos And Don'ts
Robot Framework Dos And Don'ts
 
What is stlc
What is stlcWhat is stlc
What is stlc
 
8 - Javascript unit testing framework
8 - Javascript unit testing framework8 - Javascript unit testing framework
8 - Javascript unit testing framework
 
Introduzione allo Unit Testing
Introduzione allo Unit TestingIntroduzione allo Unit Testing
Introduzione allo Unit Testing
 
Practical pointers for better code review
Practical pointers for better code reviewPractical pointers for better code review
Practical pointers for better code review
 
RoboCon 2018: How did we get here? Where do we go next?
RoboCon 2018: How did we get here? Where do we go next?RoboCon 2018: How did we get here? Where do we go next?
RoboCon 2018: How did we get here? Where do we go next?
 
CLEAN CODE
CLEAN CODECLEAN CODE
CLEAN CODE
 
Android Frameworks: Highlighting the Need for a Solid Development Framework 
Android Frameworks: Highlighting the Need for a Solid Development Framework Android Frameworks: Highlighting the Need for a Solid Development Framework 
Android Frameworks: Highlighting the Need for a Solid Development Framework 
 
DrTests: The Future of Testing in Pharo
DrTests: The Future of Testing in PharoDrTests: The Future of Testing in Pharo
DrTests: The Future of Testing in Pharo
 
Technical screening .Net Developer
Technical screening  .Net DeveloperTechnical screening  .Net Developer
Technical screening .Net Developer
 
TMPA-2015: The Application of Parameterized Hierarchy Templates for Automated...
TMPA-2015: The Application of Parameterized Hierarchy Templates for Automated...TMPA-2015: The Application of Parameterized Hierarchy Templates for Automated...
TMPA-2015: The Application of Parameterized Hierarchy Templates for Automated...
 
Testing softvamp techno solutions technical interview questions for 1year exp...
Testing softvamp techno solutions technical interview questions for 1year exp...Testing softvamp techno solutions technical interview questions for 1year exp...
Testing softvamp techno solutions technical interview questions for 1year exp...
 
Effective Code Review
Effective Code ReviewEffective Code Review
Effective Code Review
 
Specifications pattern
Specifications patternSpecifications pattern
Specifications pattern
 

Similar to Getting started with unit and functional testing

Unit Testing and TDD 2017
Unit Testing and TDD 2017Unit Testing and TDD 2017
Unit Testing and TDD 2017
Xavi Hidalgo
 
Software Testing Basic Concepts
Software Testing Basic ConceptsSoftware Testing Basic Concepts
Software Testing Basic Concepts
wesovi
 
Writing Tests Effectively
Writing Tests EffectivelyWriting Tests Effectively
Writing Tests Effectively
Paul Boocock
 
Test driven development
Test driven developmentTest driven development
Test driven development
Sharafat Ibn Mollah Mosharraf
 
Unit testing
Unit testingUnit testing
Unit testing
PiXeL16
 
TDD in Python With Pytest
TDD in Python With PytestTDD in Python With Pytest
TDD in Python With Pytest
Eddy Reyes
 
Unit testing (Exploring the other side as a tester)
Unit testing (Exploring the other side as a tester)Unit testing (Exploring the other side as a tester)
Unit testing (Exploring the other side as a tester)
Abhijeet Vaikar
 
Test driven development - Zombie proof your code
Test driven development - Zombie proof your codeTest driven development - Zombie proof your code
Test driven development - Zombie proof your code
Pascal Larocque
 
May 2021 Spark Testing ... or how to farm reputation on StackOverflow
May 2021 Spark Testing ... or how to farm reputation on StackOverflowMay 2021 Spark Testing ... or how to farm reputation on StackOverflow
May 2021 Spark Testing ... or how to farm reputation on StackOverflow
Adam Doyle
 
Working With Legacy Code
Working With Legacy CodeWorking With Legacy Code
Working With Legacy Code
Andrea Polci
 
Introduzione a junit + integrazione con archibus
Introduzione a junit + integrazione con archibusIntroduzione a junit + integrazione con archibus
Introduzione a junit + integrazione con archibus
Davide Fella
 
Introduction to Continuous Delivery
Introduction to Continuous DeliveryIntroduction to Continuous Delivery
Introduction to Continuous Delivery
Giovanni Toraldo
 
Writing Tests with the Unity Test Framework
Writing Tests with the Unity Test FrameworkWriting Tests with the Unity Test Framework
Writing Tests with the Unity Test Framework
Peter Kofler
 
Project Onion unit test environment
Project Onion unit test environmentProject Onion unit test environment
Project Onion unit test environment
Abhinav Jha
 
Selenium done right
Selenium done rightSelenium done right
Selenium done right
Tal Landa
 
Session on Testing Activities in Continuous Integration and Delivery as an Ex...
Session on Testing Activities in Continuous Integration and Delivery as an Ex...Session on Testing Activities in Continuous Integration and Delivery as an Ex...
Session on Testing Activities in Continuous Integration and Delivery as an Ex...
Agile Testing Alliance
 
Testing activities in continuous integration and continuous delivery as an ex...
Testing activities in continuous integration and continuous delivery as an ex...Testing activities in continuous integration and continuous delivery as an ex...
Testing activities in continuous integration and continuous delivery as an ex...
Srinivas Kadiyala
 
Testing activities in CI/CD as exploratory tester
Testing activities in CI/CD as exploratory testerTesting activities in CI/CD as exploratory tester
Testing activities in CI/CD as exploratory tester
Srinivas Kadiyala
 
Software testing and software development process
Software testing and software development processSoftware testing and software development process
Software testing and software development process
Gen Aloys Ochola Badde
 
Test-Driven Development (TDD) in Swift
Test-Driven Development (TDD) in SwiftTest-Driven Development (TDD) in Swift
Test-Driven Development (TDD) in Swift
Amey Tavkar
 

Similar to Getting started with unit and functional testing (20)

Unit Testing and TDD 2017
Unit Testing and TDD 2017Unit Testing and TDD 2017
Unit Testing and TDD 2017
 
Software Testing Basic Concepts
Software Testing Basic ConceptsSoftware Testing Basic Concepts
Software Testing Basic Concepts
 
Writing Tests Effectively
Writing Tests EffectivelyWriting Tests Effectively
Writing Tests Effectively
 
Test driven development
Test driven developmentTest driven development
Test driven development
 
Unit testing
Unit testingUnit testing
Unit testing
 
TDD in Python With Pytest
TDD in Python With PytestTDD in Python With Pytest
TDD in Python With Pytest
 
Unit testing (Exploring the other side as a tester)
Unit testing (Exploring the other side as a tester)Unit testing (Exploring the other side as a tester)
Unit testing (Exploring the other side as a tester)
 
Test driven development - Zombie proof your code
Test driven development - Zombie proof your codeTest driven development - Zombie proof your code
Test driven development - Zombie proof your code
 
May 2021 Spark Testing ... or how to farm reputation on StackOverflow
May 2021 Spark Testing ... or how to farm reputation on StackOverflowMay 2021 Spark Testing ... or how to farm reputation on StackOverflow
May 2021 Spark Testing ... or how to farm reputation on StackOverflow
 
Working With Legacy Code
Working With Legacy CodeWorking With Legacy Code
Working With Legacy Code
 
Introduzione a junit + integrazione con archibus
Introduzione a junit + integrazione con archibusIntroduzione a junit + integrazione con archibus
Introduzione a junit + integrazione con archibus
 
Introduction to Continuous Delivery
Introduction to Continuous DeliveryIntroduction to Continuous Delivery
Introduction to Continuous Delivery
 
Writing Tests with the Unity Test Framework
Writing Tests with the Unity Test FrameworkWriting Tests with the Unity Test Framework
Writing Tests with the Unity Test Framework
 
Project Onion unit test environment
Project Onion unit test environmentProject Onion unit test environment
Project Onion unit test environment
 
Selenium done right
Selenium done rightSelenium done right
Selenium done right
 
Session on Testing Activities in Continuous Integration and Delivery as an Ex...
Session on Testing Activities in Continuous Integration and Delivery as an Ex...Session on Testing Activities in Continuous Integration and Delivery as an Ex...
Session on Testing Activities in Continuous Integration and Delivery as an Ex...
 
Testing activities in continuous integration and continuous delivery as an ex...
Testing activities in continuous integration and continuous delivery as an ex...Testing activities in continuous integration and continuous delivery as an ex...
Testing activities in continuous integration and continuous delivery as an ex...
 
Testing activities in CI/CD as exploratory tester
Testing activities in CI/CD as exploratory testerTesting activities in CI/CD as exploratory tester
Testing activities in CI/CD as exploratory tester
 
Software testing and software development process
Software testing and software development processSoftware testing and software development process
Software testing and software development process
 
Test-Driven Development (TDD) in Swift
Test-Driven Development (TDD) in SwiftTest-Driven Development (TDD) in Swift
Test-Driven Development (TDD) in Swift
 

Recently uploaded

8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
kalichargn70th171
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
Google
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
Rakesh Kumar R
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
Peter Muessig
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
Sven Peters
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
Peter Muessig
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
Shane Coughlan
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
TheSMSPoint
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
Hornet Dynamics
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
Remote DBA Services
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
Octavian Nadolu
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
Green Software Development
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
Aftab Hussain
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
Green Software Development
 
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise EditionWhy Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Envertis Software Solutions
 
SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024
Hironori Washizaki
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
brainerhub1
 
What is Master Data Management by PiLog Group
What is Master Data Management by PiLog GroupWhat is Master Data Management by PiLog Group
What is Master Data Management by PiLog Group
aymanquadri279
 

Recently uploaded (20)

8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
 
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise EditionWhy Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
 
SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
 
What is Master Data Management by PiLog Group
What is Master Data Management by PiLog GroupWhat is Master Data Management by PiLog Group
What is Master Data Management by PiLog Group
 

Getting started with unit and functional testing

  • 1. Getting started with Testing Adewale Andrade. 28/07/2017, Salvador, Bahia
  • 2. WHY TEST? ○ Know that your code works…(and doesn’t breaks anyone else’s). ○ Make deliveries and deploys more stable…. ○ Saves time (and pain) wasted on bug fixing later… ○ Improving code designs and refactoring… ○ Reduce fear of failing...
  • 3. TYPES OF TESTS (most common) ○ Unit Tests: ● Tests a small part of the application independently from other parts; (Testing one class’s method); ○ Integration Test (Functional Tests): ● Tests different parts of the application working together; (Testing a controller using multiple classes) ○ End-To-End Tests (E2E): ● Tests whether the flow of an application performs as designed from start to finish; (Testing a login flow)
  • 4. OUR STACK ○ PHPUnit ○ Neos Flow ○ PHP 5.5.9 ○ Apache 2
  • 5. OK… BUT….. What are we really testing?
  • 7. “When testing, face the code like a complete stranger… You have no idea how it does what it should do… But you know your expectations!
  • 8. WHAT MAKES A GOOD UNIT TEST? ○ Unit tests should be: ● Easy to write; ● Easy to read; ● Fast; ● Not an integration test ■ No access to external resources (network, databases, file systems, etc.)
  • 11. WHAT DO YOU NEED TO KNOW? ○ What are you testing? ○ How should it behave? ○ What are the edge cases? ○ Mapped entries? ○ Expected results?
  • 12. OK… BUT….. Does the code quality even matter?
  • 13.
  • 14. THINGS TO AVOID As much as possible!
  • 17. WHEN TO USE EACH ONE ○ Unit Tests: ● Models ● Services methods that don’t have internal dependencies; ○ Integration Tests: ● Controllers; ● Services; ● Repositories;
  • 18. HANDLING DEPENDENCIES ○ Unit tests: ● Maybe you should refactor it…. ● Dependency Injection; ● Mocking; ● Maybe it is an integration test; https://jtreminio.com/2013/03/unit-testing-tutorial-part-4-mock-objects-stub-methods-depen dency-injection/
  • 19. HANDLING DEPENDENCIES ○ Integration tests: ● Dependency Injection; ● Mocking; ● Do not mock things that you are testing.
  • 21. REINFORCING THE CULTURE ○ Pull Requests + Code Review ○ Continuous Integration Servers ● Coverage Tests ● Build Breaking and Notifying ○ Leading by example
  • 22. Thanks ;) “With faith, my brother” Adewale Andrade Software Engineer @Agilize Contabilidade Online adewale.andrade@gmail.com