Visual Studio and TFS have both tools to collect and report on code coverage for a project or solution. What we're interested in knowing, though, is how much of the changed code has been covered by tests. We'd like to be able to identify a baseline changeset in TFS and then get a report on what code was changed in the current build, what portion of it was covered by testing, and most importantly, what portion wasn't. As far as I can see, the code coverage reports and analysis in Visual Studio don't take into consideration what code has changed--they only tell you about code coverage for the entire project or solution.
2 Answers
Unfortunately, there's no out of the box functionality from TFS or Visual Studio for getting what you want.
The Code Churn and Code Coverage perspectives from the TFS data warehouse won't help much as the code churn perspective only tracks lines of code that changed, not which methods were changed.
Looking at an alternate option, you might be able to get what you're after using SonarQube's differential views but they are date based, not changeset/commit based. Plus the SCM plugin needed hasn't been tested against TF Version Control so I don't know if it will work (I haven't tried it myself). If you're using git with TFS then it should work fine, you'll just have to go through the hassle of setting it all up.
If you are looking at alternatives, NDepend can provide this feature and it has pretty good integration with Visual Studio.
NDepend lets you compare two versions of a codebase. You are able to choose what the baseline is, for example a specific build from last release or just the previous build. You can then query against the diff.