News Feed
Sections
News Archive


Community Events
php|tek 2008 PHP Conference



Sebastian Bergmann's Blog:
Generating Code from Tests
0 comments :: posted Thursday March 13, 2008 @ 08:43:50
voice your opinion now!

Sebastian Bergmann has posted a quick example of how to use the PHPUnit unit testing suite for PHP to create code for you (assuming you're using the test first method of development.

His example builds the class off of a set of test for a "BowlingGame" that ends up with roll() and score() methods based off of the naming conventions used in the test:

Following the convention that the tests for a class BowlingGame (see below) are written in a class named BowlingGameTest (see above), the test case class' source is searched for variables that reference objects of the BowlingGame class and analyzing what methods are called on these objects.
tagged with: phpunit generate code unittest testfirst programming



developer package PHP5 security zendframework ajax zend release job releases database pecl conference code framework application mysql book PEAR cakephp

All content copyright, 2008 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework