Today I was asked what I thought about asking each of our feature teams to report the total number of new unit tests created during their iteration. My knee-jerk reaction was to ask the person WTF were they thinking. However, my better sense (yea, I have a little common sense) kicked in.
Before I started to explain my point of view, I asked the person what the intent of this requirement was? Their reasons were below:
- With this in place it will keep the developers inline in terms of knowing that creating tests is important
- More tests == more coverage which SHOULD increase code quality
- Simple measurement tool to track work items
Once all the points were stated, only then did I state my view.
- Reason: With this in place it will keep the developers inline in terms of knowing that creating tests is important
I am ok with this being a goal as it is important for each developer to clearly understand what is expected of them when creating code. However, I would rather show them why creating unit tests should lead to better code with less bugs rather than force them to write tests or else.
We as a profession need to start taking the stance that we must convince or persuade developers, but rather show them why one way may be preferred or better.
- Reason: More tests == more coverage which SHOULD increase code quality
In general principle I agree with this statement, however unit test count is NOT a good measure. Here is why:
I could spend 2-3 hours creating a single unit test that proves out a extremely critical path in code which adds great value or I can spend 2-3 hours created 20+ test that add little to no value. It is because of this single fact that count of tests (like lines of code count) can be a very, very useless measure.
- Reason: Simple measurement tool to track work items
Well, I guess there is only one thing I could say for this one….When should I turn in my TPS reports
Anyway, If you are reading this and can take anything away, it should be this. Measurements are good, but make sure you are measuring the right metric. In terms of measuring code, lines of code and count of tests may not be the best measurement.
Till next time,
08-21-2009 9:08 AM