Just short of four years ago, I came up with an idea for replacing static/sealed methods in legacy code (the Michael Feathers kind) with fakes for testing purposes. Here's a quick rundown of what happened after I had that idea:
- Messed my brain up trying, for several hours over the course of many days, to figure out how to bend PostSharp to my will
- Left it alone for months
- Came back to it and spent several hours re-learning what I needed to know
- Left it alone for months
- Came back to it again and spent several hours re-learning what I needed to know
- Left it alone for months
- Came back to it and decided to try using LinFu as the AOP framework driving things
- Had what seemed like a pretty decent prototype working based on a dozen or so unit tests that fell apart under a little more weight
- Gave up on LinFu and left it alone for a few months
- Started over using Microsoft CCI Code Model to create my own specialized AOP framework to drive the mocking framework
- Made minor advances
- Left it alone for months
- Made minor advances
- Left it alone for months
- Paddle the paddle to the side to the side, To the side to the side to the paddle the paddle
- ...
- Finally started getting a bit more serious, found a decent development workflow, and started banging out some features
So that's where things stand now - there's repo over on GitHub with some really horrendous code in it that passes a handful of tests while being pretty much unusable in real-world scenarios.
For the most part I'm having fun with it and just trying to get it into a somewhat stable state. (I'd like to say it's always fun, but it's actually not, probably because I'm doing something wrong. I'll try to explore that in a later post.) Once I get the 'basic' features implemented, along with one or two other critical usability pieces, I'll starting publicizing it in an attempt to get people to use it. A main test for me is getting it to work on a few libraries in the codebase at my current job - and even for the implemented features, it does not.
But I Need to Fake Static Methods!
You have plenty of options:
- Functionally, far and away the best option is TypeMock
- TypeMock has a competitor
- I'm pretty sure support for this free alternative will be baked into VS 2012
- Pretty soon all the cool kids will be doing this; at that point in time, I'll hang my head in dismay for having spent too much time ponging around
Comments