News Feed
Sections




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

PHPMaster.com:
Preventing Code Rot 101 Unit Testing
February 28, 2013 @ 13:41:32

On PHPMaster.com today they've published a new article from Remi Woler about preventing "code rot" in your applications through the use of unit testing. He advocates that tests, when applied correctly, can help make refactoring easier and safer, allowing you to change your code and know things stlll work.

Unless you're working on a fresh project right now, the codebase you work with most likely has such code you take for granted. And the more challenging your current assignment (or fresh project) is, the more likely it will become a legacy part as well on short notice. Since it's infeasible to fully comprehend all problems that your codebases solve, as well as all their solutions, something else needs to be done to prevent code rot. One way or the other: the code needs to be refactorable to live happily ever after.

The breaks down the steps that a unit test should follow on its most base level - assemble the environment to test inside, act on the code and assert that the output was as expected. He walks you through each of these steps, detailing what's involved and including some sample code to illustrate. He also includes a few tips on the successful application of tests like:

  • Don't forget to write integration/acceptance tests as well.
  • Name your unit tests verbosely.
  • Write unit tests for bug fixes.
  • Never change the code under test.
0 comments voice your opinion now!
unittest coderot refactor application steps tutorial


blog comments powered by Disqus

Similar Posts

Ibuildings techPortal: Tips for Working with DateTime in PHP

Zend Developer Zone: Dynamically Generating PDF Files with PHP and Haru

James Morris' Blog: A Symfony2 Console Command and the Foursquare API Venuehistory

Icant.co.uk: How to create thumbnails with PHP and gd

WorkingSoftware.com.au: Configuring PHP4 and PHP5 to run concurrently on FreeBSD


Community Events





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


opinion laravel symfony2 developer refactor api code install series release community testing framework unittest threedevsandamaybe interview introduction podcast language list

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