When dealing with legacy systems or those not designed with specific testability scenarios in mind, you have to test your changes in non-traditional means. In normal mocking (or test double ) scenarios, you have some kind of external dependency that you want to substitute for. For example, you might...
I've been extending a legacy codebase lately to make it a bit more testable, and a few small, bad decisions have slowed my progress immensely. One decision isn't bad in and of itself, but a small bad decision multiplied a hundred times leads to significant pain. It's death by a thousand cuts...
And now, for another tale of legacy code woe, here's a gut-wrenching tragedy of OCP and downcasting , in five acts . Exposition We have a feature we're implementing that when the store's configuration settings allow for a survey link to be shown, it should show up, otherwise, it shouldn't...
This post was originally published here . One of the core techniques in Michael Feathers' Working Effectively With Legacy Code is the "Subclass and Override Method" technique. Basically, in the context of a test, we can subclass a dependency and override behavior on a method or property...