Automated Testing in WordPress, Really?!

Download Automated Testing in WordPress, Really?!

Post on 08-May-2015

8.217 views

Category:

Technology

0 download

Embed Size (px)

DESCRIPTION

Did you know that WordPress has an automated test suite? It contains well over 1500 integration tests and growing. However one of the primary culprits of WordPress is in the quality of its plugins. Most plugins don't have an automated test suite you can run to verify all features are working as expected, and fail gracefully. In this talk, Ptah will introduce you to automated testing in WordPress using PHPUnit. We will cover concepts like unit testing, integration testing and end-to-end testing with examples in WordPress. You will leave the talk equipped with practical knowledge and ready to start adding an automated test suite to your plugins.

TRANSCRIPT

<ul><li>1.Automated Testing inWordPress, Really?! Rate this talk: https://joind.in/10115#dc4d - Automated Testing in WordPress with @ptahdunbar</li></ul> <p>2. Ptah (Pirate) DunbarStarted with WordPress and PHP in 05Contributing developer to WordPress, BuddyPress, bbPressFull stack Web DeveloperArchitect at LiveNinja.comWPMIA co-organizer and SoFloPHP member Became Pirate Dunbar#dc4d - Automated Testing in WordPress with @ptahdunbar 3. Ptah (Pirate) DunbarStarted with WordPress and PHP in 05Contributing developer to WordPress, BuddyPress, bbPressFull stack Web DeveloperArchitect at LiveNinja.comWPMIA co-organizer and SoFloPHP member Became Pirate Dunbar#dc4d - Automated Testing in WordPress with @ptahdunbar 4. Ptah (Pirate) DunbarStarted with WordPress and PHP in 05Contributing developer to WordPress, BuddyPress, bbPressFull stack Web DeveloperArchitect at LiveNinja.comWPMIA co-organizer and SoFloPHP member Became Pirate Dunbar#dc4d - Automated Testing in WordPress with @ptahdunbar 5. AgendaIn one hour Understand automated testing concepts, ideas and best practices. Learn PHPUnit basics and the WordPress testsuite. Resources and homework#dc4d - Automated Testing in WordPress with @ptahdunbar 6. WordPress powers1 in 5 websites source: http://w3techs.com/blog/entry/wordpress_powers_1_in_5_websites#dc4d - Automated Testing in WordPress with @ptahdunbar 7. WordPress community28,510 2,177 source: http://w3techs.com/blog/entry/wordpress_powers_1_in_5_websites#dc4d - Automated Testing in WordPress with @ptahdunbar 8. The result is that a lot of the plugins are written in poor code and turn out to be poorly compatible with other plugins Yoasthttp://yoast.com/plugin-future/#dc4d - Automated Testing in WordPress with @ptahdunbar 9. Fail. 10. Manual TestingPull out the tools WP_DEBUG var_dump(); print_r(); error_log(); debug_backtrace();#dc4d - Automated Testing in WordPress with @ptahdunbar 11. Manual TestingPull out the tools WP_DEBUG var_dump(); Temporary Ad-hoc &amp; print_r(); error_log(); debug_backtrace();#dc4d - Automated Testing in WordPress with @ptahdunbar 12. Manual TestingPull out the tools WP_DEBUG var_dump(); Error Prone SLOW &amp; print_r(); error_log(); debug_backtrace();#dc4d - Automated Testing in WordPress with @ptahdunbar 13. Manual TestingPull out the tools WP_DEBUG var_dump(); Doesnt scale print_r(); error_log(); debug_backtrace();#dc4d - Automated Testing in WordPress with @ptahdunbar 14. #dc4d - Automated Testing in WordPress with @ptahdunbar 15. Automated TestingA scripted process that invokes your app to test features and compares the outcome with expected results.#dc4d - Automated Testing in WordPress with @ptahdunbar 16. Automated TestingPersistent var_dumps();#dc4d - Automated Testing in WordPress with @ptahdunbar 17. Automated TestingBetter than checking the logs#dc4d - Automated Testing in WordPress with @ptahdunbar 18. The Bigger PictureContinuous Integration vagrant PhingContinuous DeliveryBDDAutomated Testing Scrum AgileTDDContinuous Inspection Releasing early, releasing often #dc4d - Automated Testing in WordPress with @ptahdunbar 19. Automate TestingGetting started#dc4d - Automated Testing in WordPress with @ptahdunbar 20. CHOOSE YOUR FRAMEWORKThere are so manyFrameworks #dc4d - Automated Testing in WordPress with @ptahdunbar 21. CHOOSE YOUR FRAMEWORKPHPUnit http://phpunit.de/manual/ Sebastian Bergmann#dc4d - Automated Testing in WordPress with @ptahdunbar 22. { "require-dev": { "phpunit/phpunit": "3.7.*", "phpunit/phpunit-selenium" : "*", } }http://getcomposer.orgvim composer.json &amp;&amp; composer update#dc4d - Automated Testing in WordPress with @ptahdunbar 23. PHPUnit$&gt;./vendor/bin/phpunit#dc4d - Automated Testing in WordPress with @ptahdunbar 24. PHPUnitTerminology#dc4d - Automated Testing in WordPress with @ptahdunbar 25. PHPUnitTerminology Test Case A set of conditions that you set up in order to assert expected outcome.#dc4d - Automated Testing in WordPress with @ptahdunbar 26. PHPUnitTerminology Test Case A set of conditions that you set up in order to assert expected outcome. Test Class A collection of test cases, extends PHPUnit#dc4d - Automated Testing in WordPress with @ptahdunbar 27. PHPUnitTerminology Test Case A set of conditions that you set up in order to assert expected outcome. Test Class A collection of test cases, extends PHPUnit Test Suite A collection of test classes#dc4d - Automated Testing in WordPress with @ptahdunbar 28. PHPUnitTEST CLASS tests/#dc4d - Automated Testing in WordPress with @ptahdunbar 33. PHPUnitphpunit.xml tests/Configure your test suite location#dc4d - Automated Testing in WordPress with @ptahdunbar 34. PHPUnitphpunit.xml tests/integrationtests/acceptanceConfigure your test suite location#dc4d - Automated Testing in WordPress with @ptahdunbar 35. PHPUnitphpunit.xml tests/Bootstrap file is included before any tests run#dc4d - Automated Testing in WordPress with @ptahdunbar 36. PHPUnitAssertions Explicitly check expected outcome agaisnt actual outcome.#dc4d - Automated Testing in WordPress with @ptahdunbar 37. PHPUnitAssertions Explicitly check expected outcome agaisnt actual outcome. $this-&gt;assertTrue(condition);#dc4d - Automated Testing in WordPress with @ptahdunbar 38. PHPUnitArrange, Act, Assert#dc4d - Automated Testing in WordPress with @ptahdunbar 39. PHPUnitfunction testThatItsTestingTime() { 1. A 2. A 3. A }#dc4d - Automated Testing in WordPress with @ptahdunbar 40. PHPUnitfunction testThatItsTestingTime() { 1. A 2. A 3. Assert (check for the expected behavior) }#dc4d - Automated Testing in WordPress with @ptahdunbar 41. PHPUnitfunction testThatItsTestingTime() { 1. A 2. Act (call the method/trigger the action) 3. Assert (check for the expected behavior) }#dc4d - Automated Testing in WordPress with @ptahdunbar 42. PHPUnitfunction testThatItsTestingTime() { 1. Arrange (the context/dependencies) 2. Act (call the method/trigger the action) 3. Assert (check for the expected behavior) }#dc4d - Automated Testing in WordPress with @ptahdunbar 43. PHPUnitExample#dc4d - Automated Testing in WordPress with @ptahdunbar 44. PHPUnit</p>