Skip to content
Exercises to unit test legacy code
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Testing legacy code: Hard-wired dependencies

Code related to my Testing legacy code: Hard-wired dependencies blog post

What is it about?

Provides an example of existing code that needs to be unit tested. But there is one rule:

We can't change any existing code if not covered by tests. The only exception is if we need to change the code to add unit tests, but in this case, just automated refactorings (via IDE) are allowed.

Although this is a very small piece of code, it has a lot of the problems that we find in legacy code.


If you want to give it a go, the starting point is Try unit testing it following the rule above.

My solution was and

You can’t perform that action at this time.