PHPUnit @ SydPHP

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    Favorites, Groups & Events

    PHPUnit @ SydPHP - Presentation Transcript

    1. Welcome! PHPUnit @ SydPHP Sebastian Bergmann http://sebastian-bergmann.de/ December 4th 2008
    2. Who I am ● Sebastian Bergmann ● Involved in the PHP Project since 2000 ● Creator of PHPUnit ● Author, Consultant, Coach, Trainer
    3. Testing Software ● Unit Tests – Does an isolated unit of code work correctly? – Executable specification for methods, classes ● Integration Tests – Do units of code work together correctly? ● End-to-End Tests – Does the system as a whole work correctly?
    4. PHPUnit ● Test Framework – Member of the xUnit family of test frameworks – Code Coverage – Mock Objects – DbUnit ● Integration – Selenium RC – Bamboo, CruiseControl, ...
    5. PHPUnit http://www.phpunit.de/
    6. PHPUnit Installation sb@ubuntu ~ % pear channel-discover pear.phpunit.de Adding Channel \"pear.phpunit.de\" succeeded Discovery of channel \"pear.phpunit.de\" succeeded sb@ubuntu ~ % pear install phpunit/phpunit downloading PHPUnit-3.3.0.tgz ... Starting to download PHPUnit-3.3.0.tgz (264,782 bytes) ...................................done: 264,782 bytes install ok: channel://pear.phpunit.de/PHPUnit-3.3.0
    7. DEMO
    8. PHPUnit 3.3 Released in September 2008 ● Support for Behaviour-Driven Development ● Improvements to – PHPUnit_Framework_Assert – PHPUnit_Framework_TestCase – PHPUnit_Extensions_DatabaseTestCase – PHPUnit_Extensions_SeleniumTestCase – Code Coverage reporting
    9. Behaviour-Driven Development <?php require_once 'PHPUnit/Extensions/Story/TestCase.php'; require_once 'BowlingGame.php'; class BowlingGameSpec extends PHPUnit_Extensions_Story_TestCase { /** * @scenario */ public function scoreForOneSpareAnd3Is16() { $this->given('New game') ->when('Player rolls', 5) ->and('Player rolls', 5) ->and('Player rolls', 3) ->then('Score should be', 16); } // ... }
    10. Behaviour-Driven Development sb@ubuntu ~ % phpunit --story BowlingGameSpec PHPUnit 3.3.6-dev by Sebastian Bergmann. BowlingGameSpec [x] Score for one spare and 3 is 16 Given New game When Player rolls 5 and Player rolls 5 and Player rolls 3 Then Score should be 16 Scenarios: 1, Failed: 0, Skipped: 0, Incomplete: 0. sb@ubuntu ~ % phpunit --testdox BowlingGameSpec PHPUnit 3.3.6-dev by Sebastian Bergmann. BowlingGameSpec [x] Score for one spare and 3 is 16
    11. PHPUnit 3.4 Scheduled for Q1/2009 ● Isolated Test Execution ● Support for exploiting dependencies between tests to improve defect localization ● Use Text_Diff for performing and rendering diffs ● Integration with Trac ● Marked some features for removal
    12. PHPUnit 3.4 Test Dependencies <?php class ExampleTest extends PHPUnit_Framework_TestCase { public function testOne() { $this->assertTrue(FALSE); } /** * @depends testOne */ public function testTwo() { } } ?>
    13. PHPUnit 3.4 Test Dependencies sb@ubuntu ~ % phpunit --verbose ExampleTest PHPUnit 3.4.0-dev by Sebastian Bergmann. ExampleTest FS Time: 0 seconds There was 1 failure: 1) testOne(ExampleTest) Failed asserting that <boolean:false> is true. /home/sb/ExampleTest.php:6 There was 1 skipped test: 1) testTwo(ExampleTest) This test depends on \"ExampleTest::testOne\" to pass. FAILURES! Tests: 2, Assertions: 0, Failures: 1, Skipped: 1.
    14. PHPUnit 3.4 Integration with Trac <?php class ExampleTest extends PHPUnit_Framework_TestCase { /** * @ticket 2204 */ public function testSomething() { } } ?>
    15. PHPUnit 4.0 Scheduled for … “when it's ready” ● Cleanup – Remove previously deprecated features ● Refactor – Use PHP 5.3 features – Use Hamcrest as matcher library
    16. PHP QA Tool Landscape
    17. The End ● Thank you for your interest! ● These slides will be available shortly on http://sebastian-bergmann.de/talks/.
    18. License   This presentation material is published under the Attribution-Share Alike 3.0 Unported license.   You are free: ✔ to Share – to copy, distribute and transmit the work. ✔ to Remix – to adapt the work.   Under the following conditions: ● Attribution. You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work). ● Share Alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under the same, similar or a compatible license.   For any reuse or distribution, you must make clear to others the license terms of this work.   Any of the above conditions can be waived if you get permission from the copyright holder.   Nothing in this license impairs or restricts the author's moral rights.

    + Sebastian BergmannSebastian Bergmann, 11 months ago

    custom

    1154 views, 0 favs, 1 embeds more stats

    Presentation I gave on <a href=\"http://www.phpunit more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 1154
      • 1128 on SlideShare
      • 26 from embeds
    • Comments 0
    • Favorites 0
    • Downloads 21
    Most viewed embeds
    • 26 views on http://sydphp.org

    more

    All embeds
    • 26 views on http://sydphp.org

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories