Sebastian Bergmann »
08 June 2010 »
in Announcements »
To celebrate the 15th birthday of PHP, I have released PHPUnit 3.5 Beta 1 today. The refactoring towards components is a "new feature" that is already visible upon installation:
sb@vmware ~ % pear install phpunit/PHPUnit-beta
phpunit/PHPUnit can optionally use PHP extension "dbus"
downloading PHPUnit-3.5.0beta1.tgz ...
Starting to download PHPUnit-3.5.0beta1.tgz (105,588 bytes)
........................done: 105,588 bytes
downloading DbUnit-1.0.0beta1.tgz ...
Starting to download DbUnit-1.0.0beta1.tgz (38,209 bytes)
...done: 38,209 bytes
downloading File_Iterator-1.2.1.tgz ...
Starting to download File_Iterator-1.2.1.tgz (3,225 bytes)
...done: 3,225 bytes
downloading Text_Template-1.0.0.tgz ...
Starting to download Text_Template-1.0.0.tgz (2,493 bytes)
...done: 2,493 bytes
downloading PHP_CodeCoverage-1.0.0beta1.tgz ...
Starting to download PHP_CodeCoverage-1.0.0beta1.tgz (108,640 bytes)
...done: 108,640 bytes
downloading PHP_Timer-1.0.0.tgz ...
Starting to download PHP_Timer-1.0.0.tgz (2,536 bytes)
...done: 2,536 bytes
downloading PHPUnit_MockObject-1.0.0beta1.tgz ...
Starting to download PHPUnit_MockObject-1.0.0beta1.tgz (15,816 bytes)
...done: 15,816 bytes
downloading PHPUnit_Selenium-1.0.0beta1.tgz ...
Starting to download PHPUnit_Selenium-1.0.0beta1.tgz (15,298 bytes)
...done: 15,298 bytes
downloading PHP_TokenStream-1.0.0beta1.tgz ...
Starting to download PHP_TokenStream-1.0.0beta1.tgz (7,023 bytes)
...done: 7,023 bytes
install ok: channel://pear.phpunit.de/File_Iterator-1.2.1
install ok: channel://pear.phpunit.de/Text_Template-1.0.0
install ok: channel://pear.phpunit.de/PHP_Timer-1.0.0
install ok: channel://pear.phpunit.de/PHP_TokenStream-1.0.0beta1
install ok: channel://pear.phpunit.de/PHP_CodeCoverage-1.0.0beta1
install ok: channel://pear.phpunit.de/PHPUnit-3.5.0beta1
install ok: channel://pear.phpunit.de/DbUnit-1.0.0beta1
install ok: channel://pear.phpunit.de/PHPUnit_MockObject-1.0.0beta1
install ok: channel://pear.phpunit.de/PHPUnit_Selenium-1.0.0beta1
Happy Birthday PHP! And have fun testing (with) PHPUnit 3.5!
Sebastian Bergmann »
26 May 2010 »
in Events »
thePHP.cc - The PHP Consulting Company will present the following workshops and sessions at this year's International PHP Conference: Spring Edition in Berlin:
Continuous Inspection and Integration of PHP Projects
Sebastian Bergmann, 30.05.2010, 09:15 - 13:00, Room: Salon 4
Continuous Integration with automated code analysis and test execution has seen broad adoption in recent years. The ideas behind this have changed how companies look at Build Management, Release Management, Deployment Automation, and Test Orchestration. This session presents the best practices and available tools that provide an insight into the development progress and code quality.
The Cake is a Lie
Sebastian Bergmann, 31.05.2010, 09:15 - 10:15, Room: Salon 6
Even if you have not played the game "Portal" you might have come across the phrase "The cake is a lie". According to the Urban Dictionary, it roughly translates to "your promised reward is merely a fictitious motivator". Scaffolding, the meta-programming method of building software applications, promises easier development and a faster time-to-market. But the "code generation bliss" can lead to problems later on, for instance with regard to maintainability and scalability. This session takes a sceptical look at frameworks such as CakePHP and Symfony.
Building a PHP Preprocessor with Plain PHP
Arne Blankerts, 31.05.2010, 15:15 - 16:15, Room: Salon 6
Ever wished to have a preprocessor for PHP? Now you can! In this session we will implement a simple yet powerful preprocessor using the streamwrapper technology that works out of the box on any PHP installation. This opens up a whole new world of possibilities like annotation parsing, AOP, or dependency resolution in PHP development - all transparently done in the background.
Continuous Integration and Unit Testing in Agile Environments
Sebastian Bergmann, 01.06.2010, 16:00 - 17:00, Room: Salon 7
As part of the Agile Day, this session will shine a light on the roles that Continuous Integration and Unit Testing play in agile environments.
Diapers: When They Smell, Change Them
Stefan Priebsch, 30.05.2010 - 02.06.2010, Room: $HOME
Stefan Priebsch can not join us this year for the International PHP Conference: Spring Edition in Berlin. Earlier this month he became the proud father of two beautiful twins, Lara and Patrick. We hope that he will be at the International PHP Conference this fall in Mainz.
Arne and I are looking forward to see you in Berlin next week!
Sebastian Bergmann »
22 May 2010 »
in PHP »
Rather than commemorating the release of a legacy version of PHP (PHP 4.0.0 was released May 22nd 2000 and has been superseded by PHP 5 almost six years ago), this blog posting remembers the anniversary of the first gathering of the German PHP community.
In the week that PHP 4.0.0 was released I met some members of the German PHP community for the first time in person. At the Internet World fair in Berlin in May 2000 (at least) Björn Schotte, Johann-Peter Hartmann, Ulf Wendel, Kristian Köhntopp, Sascha Schumann, Volker Göbbels and myself met for dinner at a Thai restaurant. I do not remember if they joined us for dinner, but also at the fair were Tobias Ratschiller and Till Gerken.
Sebastian Bergmann »
15 April 2010 »
in Articles »
Users of PHPUnit frequently ask me questions such as "How do I use PHPUnit from a Git checkout?" or "How do I run PHPUnit's own test suite?" This article provides the answers to these questions.
Getting PHPUnit from Git
sb@thinkpad ~ % git clone git://github.com/sebastianbergmann/phpunit.git
You now have a phpunit directory in your current working directory that contains the branch for PHPUnit 3.5 (at the time of writing) because the 3.5 branch is currently configured as the default branch for the PHPUnit repository on GitHub. If you want to switch to the branch for PHPUnit 3.4, for instance, you can use
sb@thinkpad phpunit % git checkout -b 3.4 origin/3.4
This tells Git to create a new local branch of name 3.4 (-b 3.4) that is set up to track the remote branch 3.4 from origin (origin/3.4). Git automatically switches to the newly created local branch. Using
sb@thinkpad phpunit % git checkout 3.5
you can switch back to the branch for PHPUnit 3.5.
Running PHPUnit from a Git checkout
Inside the phpunit directory you will find the phpunit.php script. Using this script you can invoke the PHPUnit TextUI test runner:
sb@thinkpad ~ % phpunit/phpunit.php
PHPUnit @package_version@ by Sebastian Bergmann.
.
.
.
The @package_version@ placeholder string for the version information makes it clear that a non-release version of PHPUnit is being used. Upon installation, the PEAR Installer replaces this placeholder string with the relevant information.
Running PHPUnit's Own Test Suite
Running PHPUnit's own test suite is as easy as invoking phpunit in the checkout directory:
sb@thinkpad phpunit % phpunit
PHPUnit @package_version@ by Sebastian Bergmann.
............................................................ 60 / 681
............................................................ 120 / 681
............................................................ 180 / 681
............................................................ 240 / 681
............................................................ 300 / 681
............................................................ 360 / 681
............................................................ 420 / 681
............................................................ 480 / 681
................................SSSSSSSSSSSSSSSSSSSSSSSSSSSS 540 / 681
SSSS.......................................S................ 600 / 681
............................................................ 660 / 681
.....................
Time: 27 seconds, Memory: 56.25Mb
OK, but incomplete or skipped tests!
Tests: 681, Assertions: 1459, Skipped: 33.
Writing code coverage data to XML file, this may take a moment.
Generating code coverage report, this may take a moment.
The above works because there is an XML configuration for PHPUnit (phpunit.xml.dist) in the directory that contains information about which tests to run and what logfiles to produce.
Sebastian Bergmann »
03 April 2010 »
in Announcements »
Almost a year ago I started to factor out all the code that deals with code coverage in PHPUnit and put it into a separate component. The name of this component is PHP_CodeCoverage.
PHP_CodeCoverage is a library that provides collection, processing, and rendering functionality for PHP code coverage information. Its architecture has support for multiple backends for collecting code coverage information (currently only support for Xdebug is implemented) and for reporting code coverage information (for instance using Clover XML or as an HTML report).
As mentioned earlier, the HTML report that is generated by PHP_CodeCoverage shows the CRAP Index software metric for each function or method. Today I built on this earlier development and added a "dashboard view" to the HTML report that shows the following software metrics:
- Class Coverage Distribution: This is a bar chart that shows how many classes have 0%, ..., 100% code coverage
- Class Complexity: This is a scatter chart that shows the coverage (X axis) and the complexity (Y axis) of the classes
- Top Project Risks: This is list of the classes with the highest CRAP Index
- Least Tested Methods: This is the list of the least tested methods
You can see an example of the dashboard view below: