0
PHP, QA, and JenkinsEric CopeJune 25, 2013http://voltampmedia.com
About Me• I run Voltamp Media Inc., a 1-man web-devshop• PHP-literate since 2002• CodeIgniter since 2005 (1.6 whenever tha...
The Tools• Jenkins - http://jenkins-ci.org– Continuous Integration Tool– Basic install is a quick download then:• java –ja...
Getting Started• Open a browser to:– http://localhost:8080
Managing Jenkins• File System Location– Config files– Project build areas– Manage plugins• Start from here - http://jenkin...
The First Job• Each job must be configured!– Source Code – how to get the code– Build triggers (poll SCM, commit hooks)– B...
The ANT Script• This is auto-generated,then modified asneeded• Test by running:% ant /path/to/build.xml• More athttp://ant...
The PHPUnit Script• This is auto-generated, then modified as needed too• Test by running: % phpunit
PHPUnit Tips and Tricks - fixtures• YAML files can be used within a fixture
PHPUnit Tips and Tricks – dataproviders• YAML files canbe used as adata providertoo– Calls the provider(returns an array)–...
PHPUnit Tips and Tricks – Exceptions• Test your exceptions!• Check exception class and code
Bonus! PHPUnit and Selenium• Make Jenkins drive PHPUnit drive Selenium!
My Issues - controller• My current projects use CodeIgniter. CIUnitmakes using PHPUnit and CI better, but setupis painful....
My Issues - Selenium• Selenium has matured quite a bit, butdocumentation and support is still very lean.• PHPUnit’s Seleni...
Still to Learn/Do• Mocks• Dependency Injection• Code Coverage• DRY-er!• More Integration coverage with Selenium• Exclude E...
Upcoming SlideShare
Loading in...5
×

Azphp phpunit-jenkins

637

Published on

A brief Introduction to PHP QA using PHPUnit, Selenium and Jenkins.

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
637
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
9
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Transcript of "Azphp phpunit-jenkins"

  1. 1. PHP, QA, and JenkinsEric CopeJune 25, 2013http://voltampmedia.com
  2. 2. About Me• I run Voltamp Media Inc., a 1-man web-devshop• PHP-literate since 2002• CodeIgniter since 2005 (1.6 whenever thatwas)• Bitten by the TDD bug around 2006• Met Hudson/Jenkins in 2011
  3. 3. 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 ajava 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
  4. 4. Getting Started• Open a browser to:– http://localhost:8080
  5. 5. Managing Jenkins• File System Location– Config files– Project build areas– Manage plugins• Start from here - http://jenkins-php.org/• Get the pluginsStatic Code Analysis Plug-ins Clover PHP Plugin Plot pluginDRY Plugin Checkstyle Plugin PMD PluginGit Plugin HTML Publisher Plugin xUnit Plugin
  6. 6. 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
  7. 7. The ANT Script• This is auto-generated,then modified asneeded• Test by running:% ant /path/to/build.xml• More athttp://ant.apache.org
  8. 8. The PHPUnit Script• This is auto-generated, then modified as needed too• Test by running: % phpunit
  9. 9. PHPUnit Tips and Tricks - fixtures• YAML files can be used within a fixture
  10. 10. PHPUnit Tips and Tricks – dataproviders• YAML files canbe used as adata providertoo– Calls the provider(returns an array)– For each row it calls thetest• The YAML isdifferent!
  11. 11. PHPUnit Tips and Tricks – Exceptions• Test your exceptions!• Check exception class and code
  12. 12. Bonus! PHPUnit and Selenium• Make Jenkins drive PHPUnit drive Selenium!
  13. 13. My Issues - controller• My current projects use CodeIgniter. CIUnitmakes using PHPUnit and CI better, but setupis painful.– End case of parent controller• Correct parent class in setUp, but not in thetestMethod!• MY_Controller vs. Controller– $this->CI = set_controller(MY_Controller);
  14. 14. My Issues - Selenium• Selenium has matured quite a bit, butdocumentation and support is still very lean.• PHPUnit’s Selenium2 class is much better, but stillleaves much to be desired.– Click() does not wait for the page to load after a formsubmission. Selenese supported clickandwait(), but Ican’t find documentation…– https://github.com/sebastianbergmann/phpunit-selenium/blob/master/Tests/Selenium2TestCaseTest.php– http://stackoverflow.com/questions/9102505/phpunit-with-selenium
  15. 15. Still to Learn/Do• Mocks• Dependency Injection• Code Coverage• DRY-er!• More Integration coverage with Selenium• Exclude External Libraries in analysis || fixthem!• Better TDD / BDD
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×