I have a TFS 2013
environment setup and I am trying to get TFSBuild
to gather my code coverage results after a build.
The tests are running fine, but no matter what I try, I get a message saying "No Code Coverage Results".
I have read about a "Code Coverage Analysis Service", but that is not installed on my servers at all and I can't seem to find it anywhere.
I have gone through the process of the builds to make sure I have the "Automated Tests --> Test Source --> Run settings --> Type of run settings" set to CodeCoverageEnabled
, but no matter what else I try, I can't get the results to get published to the Analysis services database so I can run the Code Coverage Reports
.
I have tried a run settings file, but with no luck, so I have taken that out of the equation.
Any help would be greatly appreciated!
I am using local build server with Visual Studio online with a .runsettings file and I had exactly the same issue.
None of the trickery above helped, so I tested the build script on the hosted build controller and it worked fine, so I decided the problem must be the build server itself.
I changed the Build Service account from "Network Service" to a regular windows user account in the TFS Configuration Tool and now code coverage is collected. Note that this user will need access to the TFS build directories.
The above workarounds didn't work from me (VS2015 update5 & TFS2013 Update 3).
In my case, Visual Studio was not installed on the build server which is a requirement it seems for code coverage results to be returned.
From MSDN
Microsoft Visual Studio is required to be installed on the build server for the following scenarios:
To use data and diagnostic data adapters:
To build any modern style apps on a build machine: Visual Studio Ultimate or Visual Studio Express for Windows 8 (Operating system on build server must be Windows 8).
Do you have a Premium or ultimate visual studio installed on your build machine? Either of those is required to get code coverage results back to TFS
I think the "other window" is referring to right-clicking on the Solution's "Local.testsettings" file (or other [ ].testsettings files), selecting "Open" and navigating through the various setups. When you set the "Test Run location" radio button to "Run tests using local computer or a test controller", there is a setting under "Data and Diagnostics" for "Code Coverage (Visual Studio 2010)".
I just figured out what the problem was that my Code Coverage weren't been calculated on the buildserver. I figured this out with the helpdesk of Microsoft and it is a small UI bug.
Steps to reproduce: Create a new build definition.
To fix this issue use the other ui of the build definition.
Now the code coverage does get calculated!!! The microsoft helpdesk has submitted a bug to the development team and it will be fixed I guess the next release. Small bug but it cost me more then two days to find the bug!