7 Phases of Unit Testing – I Did It My Way

Karl Seguin blogged a short nice post on the "7 phases of unit testing". I’ll take the jump and see how they fit into my life.

1 – Refuse to unit test because "you don’t have enough time"

It wasn’t exactly like that – I convinced my manager, it would be better to concentrate on "real code". Don’t want to waste precious development time.

2 – Start unit testing and immediately start blogging about unit testing and TDD and how great they are and how everyone should do it

It wasn’t exactly like that - First, I didn’t have a blog then. I did, however, talked about it to anybody who was willing to listen. Or just pass by. And talking was mostly about theory. I did experiment, but only later I would integrated it on real production code.

3 – Unit test everything – make private methods internal and abuse the InternalsVisibleTo attribute. Test getters and setters or else you won’t get 100% code coverage

It wasn’t exactly like that – I made them public! What’s the difference? And of course, if you start doing TDD, it’s easiest to start with properties. The coverage thing is just a trophy, right?

4 – Get fed up with how brittle your unit tests are and start writing integration tests without realizing it.

It wasn’t exactly like that - Brittle tests mean one thing: they’re good for the writing phase, not for maintenance. And integration test are just as brittle. Better have QA test them.

5 – Discover a mocking framework and make heavy use of strict semantics

It wasn’t exactly like that – After doing hand-rolled mocks, I started reading about dynamic mocking frameworks. And decided, it’s just one more tool to learn and teach. I’ll be better off writing my own mocks.

6 – Mock absolutely everything that can possibly be mocked

It wasn’t exactly like that - well, because I chose the manual way, I didn’t have enough patience to mock everything, just what’s "important" or "easy" or "I know how it works".

7 – Start writing effective unit tests

Eventually, it did happen. But it’s a long road, and I’m enjoying it.

There you go. I don’t look that smart now, do I? Let that be a lesson to you – if you can benefit from other people’s experience, do it. Your (and my) way may not be the best and shortest to success,

TOP