Testing the Un-Testable

wood-pile-2

As developers, we are often faced with legacy code bases that were never designed with unit testing in mind. Of course, we now know the value of unit tests and we want to test as much as possible. A good place to start implementing tests in old code is to write tests around each bug and feature. Do not try to refactor the entire pile of rubble, but instead begin with tests around just the code you are adding or changing.

Here I will show you a simple technique to refactor “just enough” to get some tests running without introducing unacceptable risk in your modifications. The examples with be in C#, but the technique applies everywhere.

Continue reading

Advertisement