The QA professional is certainly needed within a company. However, in many cases, unfortunately, there are companies that don’t adhere to this professional culture. Increasing the code quality becomes a major challenge for development teams in these cases. This presentation aims to give tips learned from mistakes of this attempt to try to improve the code quality and test execution time for a quick feedback.
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
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
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.
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.
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.
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?
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.
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.
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”.
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!!!!