News Feed
Sections




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

Jani Hartikainen's Blog:
How to make your code testable
August 17, 2009 @ 07:52:22

Jani Hartikainen has posted a few suggestions on how you can structure your code to make (unit) testing it easier in the long run.

I've recently been working on a code-base which wasn't designed with test-driven development methodologies, or with unit testing in mind. As I implemented unit-tests to this code, there were some modifications I had to do on the code. Some modifications popped up more than others. There were a few things that are more common than others - Let's look at what they were and how they affect the code and tests.

He breaks it up into three different ideas - stop creating new objects in classes, keeping your methods' functionality down to a minimum and doing the same with classes. The smaller the "chunks" of code are, the easier they are to test.

0 comments voice your opinion now!
test code unittest suggestion


blog comments powered by Disqus

Similar Posts

Roy Ganor's Blog: Welcome the PDTT - PHP 5.3 Code Assist Engine Tests

Greg Beaver's Blog: Code Coverage Reporting using PEAR, PEAR2, phar, and sqlite3

Sander Van Hooft's Blog: What SugarCRM books should you read?

Symfony Blog: The wait is over: symfony 1.1 released

AppBackr Blog: Automated PHP unit testing for lazy coders


Community Events

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


podcast release api introduction unittest threedevsandamaybe language framework interview symfony version library community laravel5 opinion extension security laravel series voicesoftheelephpant

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