SlideShare una empresa de Scribd logo
1 de 49
Globalcode – Open4education
PHP Trail – Tests and PHP Continuous
Integration Environment for Agile
Development
Bruno Yukio Tanoue
Web Developer – UOL BoaCompra
Globalcode – Open4education
Bruno Tanoue
Web Developer @ UOL BoaCompra ( 3 years and
5 months)
BoaCompra Checkout and Payment Gateway.
BoaCompra Financial System.
Bachelor’s degree in Computer Science from UEM
(State University of Maringá)
Email: brunotanoue@hotmail.com
LinkedIn: https://br.linkedin.com/in/brunotanoue/en
Globalcode – Open4education
Schedule
Tests Pyramid
Solitary Unit Test x Sociable Unit Test
Optimizations for Running Tests
PHP Continuous Integration Environment
Globalcode – Open4education
Tests Pyramid
Goal: To provide an adequate tests proportion to
run and a quick feedback.
Unit Tests: To verify the quality at small code snippets
(units).
e.g., PHPUnit
Integration Tests: To test the integration of the tested
units.
e.g., PHPUnit + DBUnit
UI Tests (User Interface Tests): To validate flows and
information displayed at the user level.
e.g., Selenium Webdriver
Globalcode – Open4education
Tests Pyramid
http://martinfowler.com/bliki/TestPyramid.html
T
Globalcode – Open4education
Solitary Unit Test x
Sociable Unit Test
What is a unit test?
Concept more used and defended:
Solitary Unit Test: Methods are tested in isolation from
other internal methods and external communications
using mocks.
Mock: It’s a change of a real structure to a simulated
structure for running tests.
Globalcode – Open4education
Solitary Unit Test x
Sociable Unit Test
Solitary Unit Test
Controller Model Database
Controller Model(Mock)
Unit
Globalcode – Open4education
Solitary Unit Test x
Sociable Unit Test
Solitary Unit Test
Advantages:
Quick execution.
Faster error location.
Exception simulation.
Disadvantages:
Possible outdated mock.
False positive at tests.
Possible bug at production.
Globalcode – Open4education
Solitary Unit Test x
Sociable Unit Test
What is a unit test?
Less known concept:
Sociable Unit Test : Methods are tested in collaboration
from other internal methods and external
communications.
What is unit in this case?
It depends on the depth of your test.
Globalcode – Open4education
Unit
Solitary Unit Test x
Sociable Unit Test
Sociable Unit Test
Controller Model Database
Globalcode – Open4education
Solitary Unit Test x
Sociable Unit Test
Sociable Unit Test
Advantages:
Running tests with the real structure.
More thoroughly tested scenario (units collaboration).
Disadvantages:
Slower runtime.
High dependence among components or systems.
False negative at tests ( e.g., external communications ).
Globalcode – Open4education
Solitary Unit Test x
Sociable Unit Test
What kind of unit test is best?
It’s necessary to review each case depending on
the need and use one of two test types.
What about the tests pyramid with the sociable unit
tests?
http://martinfowler.com/bliki/UnitTest.html
TOO CONFUSING!!!!
Globalcode – Open4education
Optimizations for Running
Tests
What is important for running tests?
It must pass confidence that code is reliable.
It must be easy to understand.
The suite execution must be as fast as possible, so that
it runs as soon as possible and many times as
necessary. (e.g., every commit )
Globalcode – Open4education
Optimizations for Running
Tests
Environment Optimizations
Problems that can delay the running tests:
Network concurrence.
Database concurrence.
Possible solution: To centralize the testing environment
on a single machine, either virtual or real with its own
database for testing.
Globalcode – Open4education
Optimizations for Running
Tests
Environment Optimizations
STAGING DATABASE LOCAL TEST DATABASE
BEFORE AFTER
Globalcode – Open4education
Optimizations for Running
Tests
Code Optimizations – Unit Tests
@dataProvider : Creating a data provider to produce
entries for a test.
Globalcode – Open4education
Optimizations for Running
Tests
Without @dataProvider
Globalcode – Open4education
Optimizations for Running
Tests
With @dataProvider
Globalcode – Open4education
Optimizations for Running
Tests
Code Optimizations – UI Tests
setUp e tearDown
At the suite execution, it prevents multiple browsers stay open if
several tests fail.
Globalcode – Open4education
Optimizations for Running
Tests
Code Optimizations – UI Tests
setUpBeforeClass e tearDownAfterClass
What if instead, the browser was opened and closed once at
each test class?
Globalcode – Open4education
Optimizations for Running
Tests
Code Optimizations – UI Tests
Surefire Plugin (Running tests in parallel)
Globalcode – Open4education
Optimizations for Running
Tests
Code Optimizations – UI Tests
Results – Build #73 (Using setUp and tearDown)
Globalcode – Open4education
Optimizations for Running
Tests
Code Optimizations – UI Tests
Results – Build #75 (Using setUpBeforeClass and
tearDownAfterClass)
Globalcode – Open4education
Optimizations for Running
Tests
Code Optimizations – UI Tests
Results – Build #75 (Using setUpBeforeClass and
tearDownAfterClass)
Globalcode – Open4education
Optimizations for Running
Tests
Code Optimizations – UI Tests
Results – Build #76 (parallel tests)
Globalcode – Open4education
PHP Continuous
Integration Environment
What is a continuous integration environment?
Continuous Integration
Agile process.
It defends the continuous code delivery in a central repository in
a short time.
The code to be integrated can’t produce defects at the existing
code. (tests)
The continuous integration environment aims to
automate tasks of the continuous integration process.
Automation is important to decrease the errors of human
nature.
Globalcode – Open4education
PHP Continuous
Integration Environment
Monitoring
Central
repository
with
version
control
CI
SERVER
Globalcode – Open4education
PHP Continuous
Integration Environment
How does create a basic continuous integration
(CI) server for PHP?
Verification
and
Updating of
Repository
Copy
Running
Tests
Building
Package
Globalcode – Open4education
PHP Continuous
Integration Environment
How does create a basic continuous integration
(CI) server for PHP?
CI Tool (Jenkins, Hudson, etc..)
It’s the heart of continuous integration server, where whole code
integration process, tests and building packages is done.
Versioning Control (GIT, SVN, etc...)
The CI server will verify the central repository from time to time
checking if there was a change. If there is a change, a building
will be triggered and the local copy is updated.
Globalcode – Open4education
PHP Continuous
Integration Environment
How does create a basic continuous integration
(CI) server for PHP?
PHP/PHPUnit
Running tests to validate the integrated code.
Web Server (Apache) and Database (MySQL, SQLite,
etc...)
Support for sociable unit tests, integration tests and UI tests.
Building Tool (Maven, Ant, etc...)
Building packages.
Globalcode – Open4education
PHP Continuous
Integration Environment
Thanks champs!!! So now I’ll install everything
manually!!!!
“IT’S RIGHT!!”! :P
Globalcode – Open4education
PHP Continuous
Integration Environment
Jenkins can manage the installation of most
components through PLUGINS.
It can manage multiple component versions.
Easy installation, removal or upgrade.
Globalcode – Open4education
PHP Continuous
Integration Environment
Globalcode – Open4education
PHP Continuous
Integration Environment
Globalcode – Open4education
PHP Continuous
Integration Environment
Other useful plugins:
Clover PHP
Code coverage chart for each building.
Warnings when code coverage decreases.
Globalcode – Open4education
PHP Continuous
Integration Environment
Other useful plugins:
Clover PHP
Globalcode – Open4education
PHP Continuous
Integration Environment
Other useful plugins:
HTML Publisher
PHPUnit Log: It provides code coverage charts of each folder,
class or method.
Covered and discovered lines information and dead code.
Globalcode – Open4education
PHP Continuous
Integration Environment
Other useful plugins:
HTML Publisher
Globalcode – Open4education
PHP Continuous
Integration Environment
The continuous integration process within Jenkins
is represented by Job.
A job can be configured in a very varied way, could
represent a step in the continuous integration, like whole
continuous integration process.
It’s possible to change the step execution order within a
job through a simple “drag and drop”.
Globalcode – Open4education
PHP Continuous
Integration Environment
Globalcode – Open4education
PHP Continuous
Integration Environment
Creating and Running a PHP job in Jenkins:
Step 1: Setting up the management of source code.
Globalcode – Open4education
PHP Continuous
Integration Environment
Creating and Running a PHP job in Jenkins:
Step 2: Setting up the repository verification method
(trigger).
Globalcode – Open4education
PHP Continuous
Integration Environment
Creating and Running a PHP job in Jenkins:
Step 3: Setting up the tests.
Globalcode – Open4education
PHP Continuous
Integration Environment
Creating and Running a PHP job in Jenkins:
Step 4: Setting up the building packages.
Globalcode – Open4education
PHP Continuous
Integration Environment
Creating and Running a PHP job in Jenkins:
Step 5: Saving and executing!!!!
Globalcode – Open4education
PHP Continuous
Integration Environment
Execution Logs:
Globalcode – Open4education
PHP Continuous
Integration Environment
Execution Logs:
Globalcode – Open4education
PHP Continuous
Integration Environment
Execution Logs:
Globalcode – Open4education
THE END
Email: brunotanoue@hotmail.com
Any doubt?Any doubt?

Más contenido relacionado

La actualidad más candente

Introduction to test automation in java and php
Introduction to test automation in java and phpIntroduction to test automation in java and php
Introduction to test automation in java and php
Tho Q Luong Luong
 
Test Driven iOS Development (TDD)
Test Driven iOS Development (TDD)Test Driven iOS Development (TDD)
Test Driven iOS Development (TDD)
Babul Mirdha
 

La actualidad más candente (18)

NIWeek 2017 - Automated Test of LabVIEW FPGA Code: CI and Jenkins 2 Pipelines
NIWeek 2017 - Automated Test of LabVIEW FPGA Code: CI and Jenkins 2 PipelinesNIWeek 2017 - Automated Test of LabVIEW FPGA Code: CI and Jenkins 2 Pipelines
NIWeek 2017 - Automated Test of LabVIEW FPGA Code: CI and Jenkins 2 Pipelines
 
Android Devops : Master Continuous Integration and Delivery
Android Devops : Master Continuous Integration and DeliveryAndroid Devops : Master Continuous Integration and Delivery
Android Devops : Master Continuous Integration and Delivery
 
Automation testing material by Durgasoft,hyderabad
Automation testing material by Durgasoft,hyderabadAutomation testing material by Durgasoft,hyderabad
Automation testing material by Durgasoft,hyderabad
 
Project Management: Burn-Down Chart / OrangeHRM Project MOD (eng)
Project Management: Burn-Down Chart / OrangeHRM Project MOD (eng)Project Management: Burn-Down Chart / OrangeHRM Project MOD (eng)
Project Management: Burn-Down Chart / OrangeHRM Project MOD (eng)
 
Testing Tools
Testing ToolsTesting Tools
Testing Tools
 
Delivering Quality Software with Continuous Integration
Delivering Quality Software with Continuous IntegrationDelivering Quality Software with Continuous Integration
Delivering Quality Software with Continuous Integration
 
Model-based Testing: Taking BDD/ATDD to the Next Level
Model-based Testing: Taking BDD/ATDD to the Next LevelModel-based Testing: Taking BDD/ATDD to the Next Level
Model-based Testing: Taking BDD/ATDD to the Next Level
 
Refactoring Legacy Code
Refactoring Legacy CodeRefactoring Legacy Code
Refactoring Legacy Code
 
Prg 218 entire course
Prg 218 entire coursePrg 218 entire course
Prg 218 entire course
 
Data Generation with PROSPECT: a Probability Specification Tool
Data Generation with PROSPECT: a Probability Specification ToolData Generation with PROSPECT: a Probability Specification Tool
Data Generation with PROSPECT: a Probability Specification Tool
 
Codeception Testing Framework -- English #phpkansai
Codeception Testing Framework -- English #phpkansaiCodeception Testing Framework -- English #phpkansai
Codeception Testing Framework -- English #phpkansai
 
Practical Software Testing Tools
Practical Software Testing ToolsPractical Software Testing Tools
Practical Software Testing Tools
 
Realtime selenium interview questions
Realtime selenium interview questionsRealtime selenium interview questions
Realtime selenium interview questions
 
Unit 2 unit testing
Unit 2   unit testingUnit 2   unit testing
Unit 2 unit testing
 
User story workflow (eng)
User story workflow (eng)User story workflow (eng)
User story workflow (eng)
 
Software testing tools
Software testing toolsSoftware testing tools
Software testing tools
 
Introduction to test automation in java and php
Introduction to test automation in java and phpIntroduction to test automation in java and php
Introduction to test automation in java and php
 
Test Driven iOS Development (TDD)
Test Driven iOS Development (TDD)Test Driven iOS Development (TDD)
Test Driven iOS Development (TDD)
 

Similar a [ENGLISH] TDC 2015 - PHP Trail - Tests and PHP Continuous Integration Environment for Agile Development

Automated Software Testing Framework Training by Quontra Solutions
Automated Software Testing Framework Training by Quontra SolutionsAutomated Software Testing Framework Training by Quontra Solutions
Automated Software Testing Framework Training by Quontra Solutions
Quontra Solutions
 

Similar a [ENGLISH] TDC 2015 - PHP Trail - Tests and PHP Continuous Integration Environment for Agile Development (20)

Release Automation: Better Quality, Faster Deployment, Amazing ROI
Release Automation: Better Quality, Faster Deployment, Amazing ROIRelease Automation: Better Quality, Faster Deployment, Amazing ROI
Release Automation: Better Quality, Faster Deployment, Amazing ROI
 
DevOps CI Automation Continuous Integration
DevOps CI Automation Continuous IntegrationDevOps CI Automation Continuous Integration
DevOps CI Automation Continuous Integration
 
Anatomy of a Build Pipeline
Anatomy of a Build PipelineAnatomy of a Build Pipeline
Anatomy of a Build Pipeline
 
Back to basics - PHPUnit
Back to basics - PHPUnitBack to basics - PHPUnit
Back to basics - PHPUnit
 
Getting Started with Test-Driven Development at Longhorn PHP 2023
Getting Started with Test-Driven Development at Longhorn PHP 2023Getting Started with Test-Driven Development at Longhorn PHP 2023
Getting Started with Test-Driven Development at Longhorn PHP 2023
 
Codeception: introduction to php testing
Codeception: introduction to php testingCodeception: introduction to php testing
Codeception: introduction to php testing
 
DevOps and Build Automation
DevOps and Build AutomationDevOps and Build Automation
DevOps and Build Automation
 
Codeception: introduction to php testing (v2 - Aberdeen php)
Codeception: introduction to php testing (v2 - Aberdeen php)Codeception: introduction to php testing (v2 - Aberdeen php)
Codeception: introduction to php testing (v2 - Aberdeen php)
 
Agile A to Z Chapter 4 Feedback Loop Part 2 DevOps
Agile A to Z Chapter 4 Feedback Loop Part 2 DevOpsAgile A to Z Chapter 4 Feedback Loop Part 2 DevOps
Agile A to Z Chapter 4 Feedback Loop Part 2 DevOps
 
Automated Software Testing Framework Training by Quontra Solutions
Automated Software Testing Framework Training by Quontra SolutionsAutomated Software Testing Framework Training by Quontra Solutions
Automated Software Testing Framework Training by Quontra Solutions
 
Performance profiling and testing of symfony application 2
Performance profiling and testing of symfony application 2Performance profiling and testing of symfony application 2
Performance profiling and testing of symfony application 2
 
Solving the Automation Puzzle - how to select the right automation framework ...
Solving the Automation Puzzle - how to select the right automation framework ...Solving the Automation Puzzle - how to select the right automation framework ...
Solving the Automation Puzzle - how to select the right automation framework ...
 
Part 2 improving your software development v1.0
Part 2   improving your software development v1.0Part 2   improving your software development v1.0
Part 2 improving your software development v1.0
 
Quality for developers
Quality for developersQuality for developers
Quality for developers
 
Continuous Integration In Php
Continuous Integration In PhpContinuous Integration In Php
Continuous Integration In Php
 
varun JENKINS.pptx
varun JENKINS.pptxvarun JENKINS.pptx
varun JENKINS.pptx
 
Agile Bodensee - Testautomation & Continuous Delivery Workshop
Agile Bodensee - Testautomation & Continuous Delivery WorkshopAgile Bodensee - Testautomation & Continuous Delivery Workshop
Agile Bodensee - Testautomation & Continuous Delivery Workshop
 
Agile Engineering Sparker GLASScon 2015
Agile Engineering Sparker GLASScon 2015Agile Engineering Sparker GLASScon 2015
Agile Engineering Sparker GLASScon 2015
 
Mastering DevOps-Driven Data Integration with FME
Mastering DevOps-Driven Data Integration with FMEMastering DevOps-Driven Data Integration with FME
Mastering DevOps-Driven Data Integration with FME
 
Framework
FrameworkFramework
Framework
 

Último

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Último (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
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
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 

[ENGLISH] TDC 2015 - PHP Trail - Tests and PHP Continuous Integration Environment for Agile Development

  • 1. Globalcode – Open4education PHP Trail – Tests and PHP Continuous Integration Environment for Agile Development Bruno Yukio Tanoue Web Developer – UOL BoaCompra
  • 2. Globalcode – Open4education Bruno Tanoue Web Developer @ UOL BoaCompra ( 3 years and 5 months) BoaCompra Checkout and Payment Gateway. BoaCompra Financial System. Bachelor’s degree in Computer Science from UEM (State University of Maringá) Email: brunotanoue@hotmail.com LinkedIn: https://br.linkedin.com/in/brunotanoue/en
  • 3. Globalcode – Open4education Schedule Tests Pyramid Solitary Unit Test x Sociable Unit Test Optimizations for Running Tests PHP Continuous Integration Environment
  • 4. Globalcode – Open4education Tests Pyramid Goal: To provide an adequate tests proportion to run and a quick feedback. Unit Tests: To verify the quality at small code snippets (units). e.g., PHPUnit Integration Tests: To test the integration of the tested units. e.g., PHPUnit + DBUnit UI Tests (User Interface Tests): To validate flows and information displayed at the user level. e.g., Selenium Webdriver
  • 5. Globalcode – Open4education Tests Pyramid http://martinfowler.com/bliki/TestPyramid.html T
  • 6. Globalcode – Open4education Solitary Unit Test x Sociable Unit Test What is a unit test? Concept more used and defended: Solitary Unit Test: Methods are tested in isolation from other internal methods and external communications using mocks. Mock: It’s a change of a real structure to a simulated structure for running tests.
  • 7. Globalcode – Open4education Solitary Unit Test x Sociable Unit Test Solitary Unit Test Controller Model Database Controller Model(Mock) Unit
  • 8. Globalcode – Open4education Solitary Unit Test x Sociable Unit Test Solitary Unit Test Advantages: Quick execution. Faster error location. Exception simulation. Disadvantages: Possible outdated mock. False positive at tests. Possible bug at production.
  • 9. Globalcode – Open4education Solitary Unit Test x Sociable Unit Test What is a unit test? Less known concept: Sociable Unit Test : Methods are tested in collaboration from other internal methods and external communications. What is unit in this case? It depends on the depth of your test.
  • 10. Globalcode – Open4education Unit Solitary Unit Test x Sociable Unit Test Sociable Unit Test Controller Model Database
  • 11. Globalcode – Open4education Solitary Unit Test x Sociable Unit Test Sociable Unit Test Advantages: Running tests with the real structure. More thoroughly tested scenario (units collaboration). Disadvantages: Slower runtime. High dependence among components or systems. False negative at tests ( e.g., external communications ).
  • 12. Globalcode – Open4education Solitary Unit Test x Sociable Unit Test What kind of unit test is best? It’s necessary to review each case depending on the need and use one of two test types. What about the tests pyramid with the sociable unit tests? http://martinfowler.com/bliki/UnitTest.html TOO CONFUSING!!!!
  • 13. Globalcode – Open4education Optimizations for Running Tests What is important for running tests? It must pass confidence that code is reliable. It must be easy to understand. The suite execution must be as fast as possible, so that it runs as soon as possible and many times as necessary. (e.g., every commit )
  • 14. Globalcode – Open4education Optimizations for Running Tests Environment Optimizations Problems that can delay the running tests: Network concurrence. Database concurrence. Possible solution: To centralize the testing environment on a single machine, either virtual or real with its own database for testing.
  • 15. Globalcode – Open4education Optimizations for Running Tests Environment Optimizations STAGING DATABASE LOCAL TEST DATABASE BEFORE AFTER
  • 16. Globalcode – Open4education Optimizations for Running Tests Code Optimizations – Unit Tests @dataProvider : Creating a data provider to produce entries for a test.
  • 17. Globalcode – Open4education Optimizations for Running Tests Without @dataProvider
  • 18. Globalcode – Open4education Optimizations for Running Tests With @dataProvider
  • 19. Globalcode – Open4education Optimizations for Running Tests Code Optimizations – UI Tests setUp e tearDown At the suite execution, it prevents multiple browsers stay open if several tests fail.
  • 20. Globalcode – Open4education Optimizations for Running Tests Code Optimizations – UI Tests setUpBeforeClass e tearDownAfterClass What if instead, the browser was opened and closed once at each test class?
  • 21. Globalcode – Open4education Optimizations for Running Tests Code Optimizations – UI Tests Surefire Plugin (Running tests in parallel)
  • 22. Globalcode – Open4education Optimizations for Running Tests Code Optimizations – UI Tests Results – Build #73 (Using setUp and tearDown)
  • 23. Globalcode – Open4education Optimizations for Running Tests Code Optimizations – UI Tests Results – Build #75 (Using setUpBeforeClass and tearDownAfterClass)
  • 24. Globalcode – Open4education Optimizations for Running Tests Code Optimizations – UI Tests Results – Build #75 (Using setUpBeforeClass and tearDownAfterClass)
  • 25. Globalcode – Open4education Optimizations for Running Tests Code Optimizations – UI Tests Results – Build #76 (parallel tests)
  • 26. Globalcode – Open4education PHP Continuous Integration Environment What is a continuous integration environment? Continuous Integration Agile process. It defends the continuous code delivery in a central repository in a short time. The code to be integrated can’t produce defects at the existing code. (tests) The continuous integration environment aims to automate tasks of the continuous integration process. Automation is important to decrease the errors of human nature.
  • 27. Globalcode – Open4education PHP Continuous Integration Environment Monitoring Central repository with version control CI SERVER
  • 28. Globalcode – Open4education PHP Continuous Integration Environment How does create a basic continuous integration (CI) server for PHP? Verification and Updating of Repository Copy Running Tests Building Package
  • 29. Globalcode – Open4education PHP Continuous Integration Environment How does create a basic continuous integration (CI) server for PHP? CI Tool (Jenkins, Hudson, etc..) It’s the heart of continuous integration server, where whole code integration process, tests and building packages is done. Versioning Control (GIT, SVN, etc...) The CI server will verify the central repository from time to time checking if there was a change. If there is a change, a building will be triggered and the local copy is updated.
  • 30. Globalcode – Open4education PHP Continuous Integration Environment How does create a basic continuous integration (CI) server for PHP? PHP/PHPUnit Running tests to validate the integrated code. Web Server (Apache) and Database (MySQL, SQLite, etc...) Support for sociable unit tests, integration tests and UI tests. Building Tool (Maven, Ant, etc...) Building packages.
  • 31. Globalcode – Open4education PHP Continuous Integration Environment Thanks champs!!! So now I’ll install everything manually!!!! “IT’S RIGHT!!”! :P
  • 32. Globalcode – Open4education PHP Continuous Integration Environment Jenkins can manage the installation of most components through PLUGINS. It can manage multiple component versions. Easy installation, removal or upgrade.
  • 33. Globalcode – Open4education PHP Continuous Integration Environment
  • 34. Globalcode – Open4education PHP Continuous Integration Environment
  • 35. Globalcode – Open4education PHP Continuous Integration Environment Other useful plugins: Clover PHP Code coverage chart for each building. Warnings when code coverage decreases.
  • 36. Globalcode – Open4education PHP Continuous Integration Environment Other useful plugins: Clover PHP
  • 37. Globalcode – Open4education PHP Continuous Integration Environment Other useful plugins: HTML Publisher PHPUnit Log: It provides code coverage charts of each folder, class or method. Covered and discovered lines information and dead code.
  • 38. Globalcode – Open4education PHP Continuous Integration Environment Other useful plugins: HTML Publisher
  • 39. Globalcode – Open4education PHP Continuous Integration Environment The continuous integration process within Jenkins is represented by Job. A job can be configured in a very varied way, could represent a step in the continuous integration, like whole continuous integration process. It’s possible to change the step execution order within a job through a simple “drag and drop”.
  • 40. Globalcode – Open4education PHP Continuous Integration Environment
  • 41. Globalcode – Open4education PHP Continuous Integration Environment Creating and Running a PHP job in Jenkins: Step 1: Setting up the management of source code.
  • 42. Globalcode – Open4education PHP Continuous Integration Environment Creating and Running a PHP job in Jenkins: Step 2: Setting up the repository verification method (trigger).
  • 43. Globalcode – Open4education PHP Continuous Integration Environment Creating and Running a PHP job in Jenkins: Step 3: Setting up the tests.
  • 44. Globalcode – Open4education PHP Continuous Integration Environment Creating and Running a PHP job in Jenkins: Step 4: Setting up the building packages.
  • 45. Globalcode – Open4education PHP Continuous Integration Environment Creating and Running a PHP job in Jenkins: Step 5: Saving and executing!!!!
  • 46. Globalcode – Open4education PHP Continuous Integration Environment Execution Logs:
  • 47. Globalcode – Open4education PHP Continuous Integration Environment Execution Logs:
  • 48. Globalcode – Open4education PHP Continuous Integration Environment Execution Logs:
  • 49. Globalcode – Open4education THE END Email: brunotanoue@hotmail.com Any doubt?Any doubt?