mahfuz01
mahfuz01

Reputation: 443

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.

Upvotes: 11

Views: 6441

Answers (3)

muhammad qasim
muhammad qasim

Reputation: 21

The problem can be solved by checking two check boxing as shown in the picture only enabling Code Coverage is not enough you need to check Upload test attachments as well in the Test Template.

enter image description here

Upvotes: 0

gordey4doronin
gordey4doronin

Reputation: 1062

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.

Upvotes: 6

Cece Dong - MSFT
Cece Dong - MSFT

Reputation: 31075

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.

Upvotes: 4

Related Questions