Enabling code coverage on TFS 2012—it’s easy
I’m so used to editing test settings to enable code coverage in TFS, that I was surprised how easy it is in TFS 2012.
First, inside Visual Studio 2012, code coverage is enabled by default. Those settings go with the unit test explorer, so they rely more on the “runsettings” file—if you even have one. If you want to customize that, check out this post.
For the build, first edit the build definition, and go to the “process” tab:
When you click on the ellipsis (“…”) next to “Automated Tests”, you’ll get this editor:
Click on the “Edit” button and you’ll get the following dialog:
Under “Options”, choose “Enable Code Coverage”. You may also want to fail the build if your unit tests fail. Keep clicking “OK” all the way out of the dialogs that were opened, and save your build definition.