Here Ya Go: Example Sh*t Test Code By Yours Truly

I'm sick of shitty legacy code.  It seems that it's everywhere and some days, like today, it takes over and makes me feel like shit.  I hate not being able to right click and choose Run Tests... and verify beyond a shadow of a doubt that code works, at least as it was intended to work.

The legacy code I'm talking about is any code I've written or helped to write that is not testable or really really difficult to test.  I'm maintaining a code base at work that grew into a monster.  It has very few tests and changing any code is major pain in my ass and usually ends up introducing new bugs.  Another project I'm working on has similar issues, rules spread out all over the place, no tests to confirm anything, totally sucks.

One thing that is common is that both projects depend heavily on hitting up external resources, database, filesystem, web pages, web services, all of the above.  One of them uses DataTables all over the place, so the consistency and reliability to know what's in it is totally missing, as opposed to just using interfaces or classes.  If you've ever heard of Mystery Meat Navigation, this is the same thing, Mystery Meat Objects, no guarantee on what's inside...

I'm not alone.  Just google for testing legacy code and see many others enduring the same pain.

I've also noticed that some of the tests that I have written are too complicated.  The type of tests I'm talking about are ones that involve complex object models, they make it hard to follow what's actually being tested.

Grrrr... I hate legacy code


 
Author: , 0000-00-00