No code coverage in TFS build after 2015 upgrade - tfs

We were using TFS and VS 2013, everything was working fine. We upgraded to TFS and VS 2015. We added a new build server (Windows Server 2012 R2, Visual Studio 2015 Enterprise, DevExpress and Wix) to have a clean install.
The builds were failing Task could not find "LC.exe" using the SdkToolsPath "" ... so we changed the build template from DefaultTemplate.11.1.xaml to TfvcTemplate.12.xaml
Now it's building, but when we open the builds from the build explorer under code coverage we have No build code coverage data available. Code coverage is enabled in the build definition.

Assuming you enabled Code coverage by going to the process tab of the build definition and then expanding the Tests--Automated tests--Test Source--Run settings, and change the Type of run settings from Default to CodeCoverageEnabled.
I have tried the same steps in TFS 2015, and I can't get Code coverage either in this way.
Instead, I tried the steps below, then I can get Code coverage now:
Go to Process--Test--Automated tests--Test source in build definition.
Now in Test source row, click the button with "...".
Under "Options", select Enabled Code Coverage and save the build definition. No matter the Enabled Code Coverage option has been selected or not, you still need to save this edit. Now queue the build, you'll see the code coverage.

Related

TFS 2015 - Build failed due to exception in the test assemblies

I am trying to run a newly created Build in TFS but i am getting an error as shown in the screenshot below :
Build Configuration
I tried to debug the Unit Test project on my machine and even on the TFS server, it worked fine. So i am not able to understand if there is any configuration missing or issue in the test assemblies code?
Update
Since VS is installed after the build agent configured. Then reregister the build agent with TFS, since the system capabilities are only discovered when the agent is first configured -- any changes made after that are not captured.
First you could also Enable Verbose Debug Mode for TFS Build vNext by add system.debug=true to get more detail log info for trobuleshooting.
According to your build log and configuration, the error occurs after code coverage warning.
Try to uncheck the code coverage option and trigger the build again.
As a prerequisite to using Code Coverage, the first thing to do is to install Visual Studio Enterprise version on the build agent.
I had installed Build Agent before installing Visual Studio. Re-configuring the Build Agent resolved the issue.

How to use code coverage tools in continuous build integration of TFS 2013?

I am using the TFS 2013\VS 2013 professional editions for continuous build. Am looking to use an open source tool like OpenCover for code coverage. I have no prior experience in code coverage tools. I installed the OpenCover UI from Nuget but not sure how to include Codecoverage in integrated build in TFS. Getting "No Code Coverage Results" when the build runs.
I enabled code coverage under Automated tests node in build definition.
Any suggestion on how to implement code coverage in TFS\VS 2013 Profession edition would be greatly appreciated.
If you mean Enabled Code Coverage in the build definition just like below screeshot.
This is VS build-in code coverage, according to the Compare VS offerings site, only Visual Studio Enterprise has Code Coverage feature, so if you use TFS for your CI build and want to use the built-in code coverage feature, installing VS Enterprise on your build agent machine is required.
If you want to integrate OpenCover with TFS XAML build, you need to customize your build process template, add a custom activity in the build definition to trigger the opencover command for generating the report.
Created a RunCoverage.cmd at the root of my source folder
Installed / copied in TFS Servers the Opencover binaries and added into Path(must restart TFS Services to enable TFS to see it).
Created a new actitivity in the build definition, that is, editing the build template (before sonar execution activity) to run the cmd:
Running command line statements from TFS custom activity
http://msdn.microsoft.com/en-us/library/gg265783.aspx
There is the cmd contents:
#REM #echo suppresses command line. ^ is line continuation character
#ECHO Executing OpenCover...
OpenCover.Console.exe -register:user ^
-target:"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\MSTest.exe" ^
-targetargs:"/testcontainer:%~dp0test.dll /usestderr /resultsfile:%~dp0MSTestsResults.trx" ^
-output:%~dp0opencovertests.xml
More details please refer Naim Raja Díaz's answer in this similar question:Integration of OpenCover with TFS 

Reconcile Workspace for TFS 2015 vNext Builds

We used to get notification from the tray of our windows machine for a finished build while using the xaml build definitions, it also had an option to reconcile workspace. The same functionality is not available for the vNext builds.
The BuildNotification App is available with VS 2015, but it seems that the reconcile workspace is not available with the vNext build. Is there some other app that can give a notification and do the reconcile operation?
We just moved to new builds (vNext) and are missing this feature as well.
Currently, we can do this manually via IDE (VS 2015):
Team Explorer -> Builds
Right click on latest build with you changes -> "Reconcile Workspace..."
The BuildNotificationApp is still a part of the VS 2015 and can be found here: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\BuildNotificationApp.exe. However, this app only applied to XAML build.
For now, to workaround the missing feature, you can use a free build status tool Catlight . It also shows status of vNext builds in tray area.
As for reconcile workspace, there is no this build-in feature for vNext build. However, you can manually use tf reconcile command for your workspace. Such as below screenshot:
Update:
If you just want a simple app or vs extension to achieve it, there is no these things for now. You may have to customize your own extension to implement it.
Update2:
I have created a feature request in uservoice:
Reconcile Workspace for vNext Build
https://visualstudio.uservoice.com/forums/330519-team-services/suggestions/15979690-reconcile-workspace-for-vnext-build
You can use AnyStatus to monitor both vNext and XAML builds.
AnyStatus comes with a feature called Triggers which lets you run a program or a batch script in response to status changes. Using Triggers you can configure it to run "tf.exe reconcile" when the build status changes from Running to OK.
Disclaimer: I am the author of Any Status.

TFS 2013 - No Code Coverage Results

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 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.
Go to the process tab of the build definition and select the solution file to build.
Now expand the "Automated tests" section and expand the "Test Source".
Expand the "Run settings" and change the "Type of run settings" from "Default" to "CodeCoverageEnabled".
Save the builddefinition and run your build.
Examine build results and notice no code coverage is calculated.
To fix this issue use the other ui of the build definition.
Select the "Automated tests" node.
Now in that row on the right you will see a button with "...". Hit it and a dialog will be opened.
Hit "Edit" to edit your test source. You will see that Code coverage is enabled. If not select it.
Hit Ok and Ok again to close the two dialogs.
Now save the build definition and run your build again.
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!
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 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 build any CPP test project, you must install Visual Studio Professional or later.
To run unit tests, or coded UI tests, you must install Visual Studio Professional or later.
To use data and diagnostic data adapters:
- Code coverage: Visual Studio Premium or later.
- Test impact: Visual Studio Ultimate.
- IntelliTrace: Visual Studio Ultimate.
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).
To compile and run tests for a project with a faked assembly: Visual Studio Ultimate.

Why Code Analysis is not working on TFS 2012 build?

As suggested in one of the related questions that you need to install VS 2012 on the TFS 2012 build server to run Code Analysis as a part of build process.
Due to some reason it is still not working nor giving any error.
Build settings for Code Analysis is set to Always but still it does not run.
However, I have open the same project on the TFS build server in VS 2012 and try to run the Code Analysis and it ran successfully.
I need to get it working.
Can anyone please suggest if I am missing anything here?
You project configuration will need a Code Analysis Ruleset to run against.
You can set this per configuration in your Project Options:

Resources