Download - PHP, QA, and Jenkins Eric Cope
![Page 1: PHP, QA, and Jenkins Eric Cope](https://reader036.vdocuments.us/reader036/viewer/2022062315/56816199550346895dd14bcf/html5/thumbnails/1.jpg)
PHP, QA, and JenkinsEric Cope
June 25, 2013http://voltampmedia.com
![Page 2: PHP, QA, and Jenkins Eric Cope](https://reader036.vdocuments.us/reader036/viewer/2022062315/56816199550346895dd14bcf/html5/thumbnails/2.jpg)
About Me
• I run Voltamp Media Inc., a 1-man web-dev shop
• PHP-literate since 2002• CodeIgniter since 2005 (1.6 whenever that
was)• Bitten by the TDD bug around 2006• Met Hudson/Jenkins in 2011
![Page 3: PHP, QA, and Jenkins Eric Cope](https://reader036.vdocuments.us/reader036/viewer/2022062315/56816199550346895dd14bcf/html5/thumbnails/3.jpg)
The Tools• Jenkins - http://jenkins-ci.org
– Continuous Integration Tool– Basic install is a quick download then:
• java –jar jenkins.war• Normal vs. LTS
– For bigger installations, its recommended to run within a java container, like Tomcat.
• PHPUnit – http://phpqatools.org– A set of QA tools– Installation is via PEAR
• Selenium – http://seleniumhq.org/– java -jar selenium-server-standalone-2.31.0.jar
![Page 4: PHP, QA, and Jenkins Eric Cope](https://reader036.vdocuments.us/reader036/viewer/2022062315/56816199550346895dd14bcf/html5/thumbnails/4.jpg)
Getting Started
• Open a browser to:– http://localhost:8080
![Page 5: PHP, QA, and Jenkins Eric Cope](https://reader036.vdocuments.us/reader036/viewer/2022062315/56816199550346895dd14bcf/html5/thumbnails/5.jpg)
Managing Jenkins
• File System Location– Config files– Project build areas– Manage plugins• Start from here - http://jenkins-php.org/• Get the plugins
Static Code Analysis Plug-ins Clover PHP Plugin Plot plugin
DRY Plugin Checkstyle Plugin PMD Plugin
Git Plugin HTML Publisher Plugin xUnit Plugin
![Page 6: PHP, QA, and Jenkins Eric Cope](https://reader036.vdocuments.us/reader036/viewer/2022062315/56816199550346895dd14bcf/html5/thumbnails/6.jpg)
The First Job
• Each job must be configured!– Source Code – how to get the code– Build triggers (poll SCM, commit hooks)– Build Steps• Scripts (very limited environment)• Maven• Ant – see http://jenkins-php.org/ for yours!
– Post Build Steps• Plots, reports
![Page 7: PHP, QA, and Jenkins Eric Cope](https://reader036.vdocuments.us/reader036/viewer/2022062315/56816199550346895dd14bcf/html5/thumbnails/7.jpg)
The ANT Script
• This is auto-generated, then modified as needed
• Test by running:% ant /path/to/build.xml
• More at http://ant.apache.org
![Page 8: PHP, QA, and Jenkins Eric Cope](https://reader036.vdocuments.us/reader036/viewer/2022062315/56816199550346895dd14bcf/html5/thumbnails/8.jpg)
The PHPUnit Script• This is auto-generated, then modified as needed too• Test by running: % phpunit
![Page 9: PHP, QA, and Jenkins Eric Cope](https://reader036.vdocuments.us/reader036/viewer/2022062315/56816199550346895dd14bcf/html5/thumbnails/9.jpg)
PHPUnit Tips and Tricks - fixtures
• YAML files can be used within a fixture
![Page 10: PHP, QA, and Jenkins Eric Cope](https://reader036.vdocuments.us/reader036/viewer/2022062315/56816199550346895dd14bcf/html5/thumbnails/10.jpg)
PHPUnit Tips and Tricks – data providers• YAML files can
be used as a data provider too– Calls the provider
(returns an array)– For each row it calls the
test
• The YAML is different!
![Page 11: PHP, QA, and Jenkins Eric Cope](https://reader036.vdocuments.us/reader036/viewer/2022062315/56816199550346895dd14bcf/html5/thumbnails/11.jpg)
PHPUnit Tips and Tricks – Exceptions• Test your exceptions!• Check exception class and code
![Page 12: PHP, QA, and Jenkins Eric Cope](https://reader036.vdocuments.us/reader036/viewer/2022062315/56816199550346895dd14bcf/html5/thumbnails/12.jpg)
Bonus! PHPUnit and Selenium
• Make Jenkins drive PHPUnit drive Selenium!
![Page 13: PHP, QA, and Jenkins Eric Cope](https://reader036.vdocuments.us/reader036/viewer/2022062315/56816199550346895dd14bcf/html5/thumbnails/13.jpg)
My Issues - controller
• My current projects use CodeIgniter. CIUnit makes using PHPUnit and CI better, but setup is painful.– End case of parent controller• Correct parent class in setUp, but not in the
testMethod!• MY_Controller vs. Controller
– $this->CI = set_controller('MY_Controller');
![Page 14: PHP, QA, and Jenkins Eric Cope](https://reader036.vdocuments.us/reader036/viewer/2022062315/56816199550346895dd14bcf/html5/thumbnails/14.jpg)
My Issues - Selenium
• Selenium has matured quite a bit, but documentation and support is still very lean.
• PHPUnit’s Selenium2 class is much better, but still leaves much to be desired.– Click() does not wait for the page to load after a form
submission. Selenese supported clickandwait(), but I can’t find documentation…
– https://github.com/sebastianbergmann/phpunit-selenium/blob/master/Tests/Selenium2TestCaseTest.php
– http://stackoverflow.com/questions/9102505/phpunit-with-selenium
![Page 15: PHP, QA, and Jenkins Eric Cope](https://reader036.vdocuments.us/reader036/viewer/2022062315/56816199550346895dd14bcf/html5/thumbnails/15.jpg)
Still to Learn/Do
• Mocks• Dependency Injection• Code Coverage• DRY-er!• More Integration coverage with Selenium• Exclude External Libraries in analysis || fix
them!• Better TDD / BDD