Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Code coverage not working TFS build

I have enabled the code coverage in the build definition for a project in TFS. enter image description here

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

enter image description here

Any help is appreciated.

like image 915
mahfuz01 Avatar asked Apr 27 '16 23:04

mahfuz01


2 Answers

Just test on my side, Code Coverage is available as expected. I'd like to share my steps for your reference:

  1. Create a default Visual Studio template.

  2. Specify the Solution in Visual Studio Build task, and check the Code Coverage Enabled in Visual Studio Test task. See the screenshots below:

enter image description here

enter image description here

Other settings are not changed.

  1. Queue build, then I can see the Code Coverage shows on build summary:

enter image description here

By the way, I'm using TFS 2015 Update2.

like image 126
Cece Dong - MSFT Avatar answered Sep 27 '22 22:09

Cece Dong - MSFT


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.

Reporting Options: Upload Test Attachments 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.
like image 24
gordey4doronin Avatar answered Sep 27 '22 23:09

gordey4doronin