Mock testing or how could I be so blind?
TDD, JUnit, mocks, blah-blah-blah. Almost everyone heard the whole buzz around these words. I used all these for more than five years. However TDD got the second bright life for me not long ago. And it’s all about mocks.
Currently I’m working on a pretty huge project with a pretty big legacy code base. Well, you know these old projects. Too big to fail and too old to get a real pleasure from the development. Too tight coupling of components, a chain of regressions even by minor changes, tickets as old as the hills. However you can still get a pleasure of these.
Mocks are just fantastic. You can mock everything, any legacy component, any static call, any private method. This feeling of power is just like the feeling of driving a real sports car. You can override any aspect of your framework. Well, I know, dynamic languages with meta-programming definitely rock but sometimes you can’t use these.
Just give it a try. If you have a legacy project – just try to write tests using mocks. It might get some time to get the taste but I bet you’ll like it. You’ll make the code more stable to changes and you can do anything you like. And yes it’s a real new development which might be just a breath of fresh air after a load of old smelly issues.