Refactoring relies on being able
to run tests to check you haven't broken anything with your 'enhancements'
and frequent testing is an essential part of extreme programmming (XP),
for more details see Extreme
Programming A Gentle Introduction, and the home site xprogramming.com
where you'll also find implementations of xUnit for other languages