Cover it up!
I’m a big fan of TDD. In an ideal world, done right, TDD should give you 100% code coverage. But this is the real world and it’s not always that easy to spot when you’ve missed an edge case. That’s why recently I’ve been looking into getting some code coverage results from my projects.
I’ve looked around quite a bit and there are some great looking tools out there for viewing code coverage, but I’m a cheapskate and a lot of these tools cost a pretty penny. Then on one of my frequent trips around nuget I discovered OpenCover. Combined with ReportGenerator it can quickly provide you with a neat little web page that shows you all kinds of useful stats from the amount of code you’ve covered with tests to the cyclomatic complexity of your functions!
It took me a little bit of powershell hacking to get it in place but I’ve now got a visual studio solution that generates on of these reports every time you hit build. It’s early days yet but so far it’s giving me great results and just adds that little bit of extra confidence that your code really is doing what you expect it to!