Cover image by Isaac Smith on Unsplash
In my last post I talked about code coverage and its usefulness as an educational milestone for any aspiring developer to conquer.
Achieving 100% code coverage will make you a better developer. Seriously.
Daniel Irvine š³ļøāš ć» Feb 11 '20
I finished the post by saying that experienced TDD practitioners have little need for code coverage because they will be hitting 100% coverage by the very nature of their development process.
But unfortunately for us, we have no good metric for measuring how effective we are with TDD.
Software design itself is fairly subjective, so thatās one reason why we donāt have a good measurement. None of us can agree.
If youāre a TDD practitioner, how do you know youāre any good?
The old āI donāt need code coverage because I do TDDā excuse
Itās been a long time since I bothered to use code coverage metrics as part of my regular development process. (To be clear, there are times when I do use code coverage--to verify coverage of a unit that I didnāt write, and to check how Iām doing when Iām using test-after with legacy code.)
When I have clients ask me why I donāt bother with code coverage, I tell them I follow āstrictā TDD so I donāt need it.
But itās an excuse. I say this because people trust me that when I say it. They think itās true, a fact. But of course itās not. I say it because Iām lazy and code coverage it just one of those things that very rarely helps me in my day-to-day. And itās mostly true.
But what happens if Iām having an off-day, or Iām in a rush?
What happens if I make accidental mistakes in my tests?
What keeps me honest?
More to the point, how do I know that Iām writing good tests, and how do I know Iām any good at software design in general?
I donāt really have the answer to that. Thereās only one way I know that really helps: working with others.
Keeping yourself honest by working with others
Pairing, and mobbing, helps you follow the TDD cycle religiously. It goes some way to stop you slipping up, cutting corners, making mistakes. Plus, itāll improve your software design.
It can help with building the right thing, too. When you mob you might have the opportunity to include a QA person within the mob. With any luck, theyāll have some input on what requirements you may be missing.
Then, as the mob signs-off work, everyone involved should be able to say they they believe they tested everything to the best of their ability.
If you have any of your own ideas about how to measure your TDD skills, Iād love to hear them.