News Feed
Jobs Feed
Sections




News Archive
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

Debuggable Blog: Code Coverage Analysis soon in CakePHP - Test How Well You Test

Michael Kimsal's Blog: Forget SEO - what about Test Optimization?

Matt Frost: Using Selenium2 with PHPUnit

Sebastian Bergmann's Blog: Improved Skeleton Generator in PHPUnit 3

SitePoint PHP Blog: The state of functional programming in PHP


Community Events









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


tool event introduction podcast community framework composer zendframework2 code interview object language functional opinion release conference api example development testing

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