PHPUnit 3.0

Sebastian Bergmann » 20 November 2006 » in Announcements » 6 Comments

Sebastian Bergmann and his contributors are proud to announce the immediate availability of PHPUnit 3. This release is a major improvement to the popular open source testing solution for PHP applications. It includes new features and bug fixes. Further details about this release can be found in the ChangeLog.

New Features
PHPUnit 3 introduces a number of new features that make it easier to use and more versatile than previous versions.
  • Mock Objects
    How can you test that a method works correctly when it is called from another method? How can you isolate your tests from external influences? Mock Objects and Stubs provide the answer to these and other questions.
  • Selenium Integration
    PHPUnit 3 integrates with Selenium RC to support both acceptance testing (by performing higher-level tests on the integrated system instead of just testing each unit of the system independently) and browser compatibility testing (by testing the web application on different operating systems and browsers).
  • Code-Coverage
    How do you test your tests? How do you find code that is not yet tested -- or, in other words, not yet covered by a test? How do you measure testing completeness? All these questions are answered by a practice called Code-Coverage Analysis. PHPUnit 3 features an improved report generator that provides detailed code-coverage information for tests run.
Installation
The PEAR channel (pear.phpunit.de) that is used to distribute PHPUnit needs to be registered with the local PEAR environment:
pear channel-discover pear.phpunit.de
This has to be done only once. Now the PEAR Installer can be used to install packages from the PHPUnit channel:
pear install phpunit/PHPUnit
Previous installations of the PHPUnit and PHPUnit2 packages from the pear.php.net channel have to be uninstalled since PHPUnit is no longer hosted on PEAR.

Upgrading from PHPUnit 2.3
PHPUnit 3 is backwards compatible with PHPUnit 2.3.

Please note that in PHPUnit versions 2.0-2.3 the class names were prefixed with PHPUnit2_ instead of PHPUnit_. Existing test cases will still work with PHPUnit version 3.0, but it is highly recommended to update them to use the new class names.

Documentation
The PHPUnit Pocket Guide has been updated for PHPUnit 3 (English, Japanese).

Please note that documenting PHPUnit is an ongoing effort. You can expect additions and improvements to the PHPUnit Pocket Guide in the future.
Defined tags for this entry: ,

Trackback specific URI for this entry

6 Comments to "PHPUnit 3.0"

Display comments as (Linear | Threaded)
  1. dammit i'm supposed to be packing for vacation
    21/11/2006 at 20:34 Permalink
    Can you bring back the toHTML and/or toString methods on test suite results? I can't find any half-decent explanation of how to use TextUI and I'm not going to write a whole listener class just so I can see the test results in my browser. I appreciate trying to make it flexible for different user interfaces or different ways to collect/store/display test results or whatever, but in trying to add this flexibility for 10% of the people who do fancy-schmancy shit, you've made life 10 times more difficult for the other 90% of us. I'd use the command-line test runner but my employee is forcing me to use a server with a frankenstein-ass setup where they try to run PHP4 and PHP5 on the same machine, and I don't have command-line access to php5, I can only get it through web server

    Reply

  2. Sebastian Bergmann
    21/11/2006 at 20:53 Permalink
    Although I am not convinced that running unit tests in the browser makes much sense I will try to look into it for PHPUnit 3.1.

    Reply

  3. Les
    31/07/2007 at 20:10 Permalink
    I would like to see this featured added as well, so that I can test from the browser.

    Simple Test has the ability to test from the browser, but I don't like that testing framework.

    Good work by the way; Lets see some more ;)

    Reply

  4. derak
    23/05/2007 at 14:47 Permalink
    Here is a good artical that explains how to run a test in the browser.
    http://www.devshed.com/c/a/PHP/Unit-Testing-in-Detail/

    The gist of it is:
    Make a test suite object and pass it to:
    PHPUnit_TextUI_TestRunner::run($suite);
    Enclose the output in 'pre' tags and it will look just like the command line.
    http://www.blooberry.com/indexdot/html/tagpages/p/pre.htm
    Nothing fancy here.

    Reply

  5. Chris Thomson
    12/01/2007 at 15:11 Permalink
    I'm intrested in using Selenium and getting code coverage results. Has anybody done such a thing with phpUnit yet?

    Thanks,

    Reply

  6. Daniel
    26/03/2007 at 19:12 Permalink
    I have code coverage results in my project.

    Reply

1 Trackback to "PHPUnit 3.0"

  1. Blog 30/11/2006 at 19:58
    Opps. Was musste ich heute festellen PHPUnit 3.0 ist draussen. Da muss ich mal direkt Testen Die AnküdigungDas Handbuch Die Homepage

Add Comment


To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

Submitted comments will be subject to moderation before being displayed.