I have enabled the code coverage in the build definition for a project in TFS.

It's building as expected, unit tests are running as well but code coverage shows "No build coverage data available" see the screenshot below.

Any help is appreciated.
Just test on my side, Code Coverage is available as expected. I'd like to share my steps for your reference:
Create a default Visual Studio template.
Specify the Solution in Visual Studio Build task, and check the Code Coverage Enabled in Visual Studio Test task. See the screenshots below:


Other settings are not changed.

By the way, I'm using TFS 2015 Update2.
The coverage result is just a file with *.coverage extension.
So enabling Code Coverage Enabled checkbox is not enough.
This checkbox enables calculating of code coverage and producing this file.
However to attach this *.coverage file to a build, you also need to enable Upload Test Attachments checkbox under Reporting Options section.
Please see the image attached.
This checkbox enables exactly what you need, it will publish coverage result against with the build.
And the final log should look something like this:
2016-10-17T15:47:03.6834453Z Attachments:
2016-10-17T15:47:03.6834453Z TFSBUILD 2016-10-17 11_46_53.coverage
2016-10-17T15:47:03.6834453Z Total tests: Passed: Failed: Skipped:
2016-10-17T15:47:03.6834453Z Test Run Successful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With