News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Sebastian Bergmann's Blog:
Generating Code from Tests
March 13, 2008 @ 08:43:50

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.
0 comments voice your opinion now!
phpunit generate unittest testfirst programming


blog comments powered by Disqus

Similar Posts

Zend Developer Zone: Episode 035: "Unit Testing in Zend Framework 1.8"

Mike Purcell's Blog: PHPUnit - Upgrade - Convert assertType to assertInternalType

Alex Netkachov's Blog: Are setters evil?

W3Techs.com: Highlights of web technology surveys, Nov. 2010: 3/4 of all websites are based on PHP

Raphael Stolt's Blog: Creating custom PHPUnit assertions


Community Events





Don't see your event here?
Let us know!


library series community podcast language laravel introduction symfony install package interview api update deployment framework opinion list release zendserver tips

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