News Feed
Sections




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

NetTuts.com:
Refactoring Legacy Code Part 4 - Our First Unit Tests
May 19, 2014 @ 13:57:41

NetTuts.com has posted the fourth part of their series guiding you through some recommended steps for refactoring legacy code. In this new post they build on the previous steps and focus more on the first steps into unit testing.

One of the key moments of refactoring a totally legacy code is when we start extracting small pieces from it and we start writing targeted unit tests for those small pieces. But this can be quite difficult, especially when you have code that is written so that it would be hard to compile or run if pieces of it are missing. We can't safely do large surgeries on a code we still barely understand and only a golden master test keeps us breaking it totally. Fortunately there are some techniques that can help us.

There's a brief introduction to unit testing and how it can be useful in a refactoring situation. They help you locate some isolated methods to start with and include a sample test (using PHPUnit). They talk about handling dependency injection, refactoring the tests themselves and working with dependencies across environments. Hints on isolating parts of the code that can be and how to refactor the tests to match are also included.

0 comments voice your opinion now!
refactor legacy code series part4 unittest phpunit

Link: http://code.tutsplus.com/tutorials/refactoring-legacy-code-part-4-our-first-unit-tests--cms-21146

blog comments powered by Disqus

Similar Posts

Jani Hartikainen's Blog: Is commenting your code useless?

Michelangelo van Dam's Blog: Quality Assurance on PHP projects - PHPUnit part 3

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

DZone.com: Refactoring away from spaghetti PHP

Sebastian Bergamnn's Blog: SeleniumTestCase Improvements in PHPUnit 3.2


Community Events

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


development extension language psr7 framework interview series laravel community wordpress introduction conference unittest laravel5 opinion release podcast api library voicesoftheelephpant

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