Test Driven Refactoring

I was working on refactoring and updating some code that was written by another team of developers today and eventually found myself in the whack-a-mole cycle of “Commit-Ship to QA-Find Bugs-Commit” for a few iterations. The project had unit tests, but they somehow didn’t cover the cases that were coming up after a few shared methods signatures had changed. I realized that through the (correct at the time) use of mock objects to get tests working at all, the tests had managed to diverge from its actual runtime behavior. It’s not just the responsibility of the initial developers to write unit tests to verify their work, it should be the responsibility of everyone who works on a project. You’ll never get perfect coverage, but if you keep it up to date, and enforce that tests must pass for the project to ship, you might have a chance at keep your code maintainable!

This entry was posted in Technology. Bookmark the permalink.