VSTest Code Coverage Value display in TFS build dashboard - (what is the Algorithm used to generate this value?) - tfs

Stackoverflow Experts,
We have a pipe line which build projects and has about 10 "Visual Studio test" tasks with Code Coverage enabled. Does anyone know how the value(73.59%) for code coverage is generated?
Refer to the attached image.

Related

How to get nUnit test report after TFS 2015 build?

Good day.
I have a TFS build and a Visual Studio Test step there. All test are run, but I can't get detailed info about them, only quantity, passed\failed\others, run duration.
Also, I see "Outcome: Failed" and "This build doesn't have test results for the outcome you've selected".
How to configure this outcome?
You can't directly use the build-in outcome to analysis the detail test result.
You need to run the Publish Test Result task. First generate an XML file which contains the results. And then use the publish results step and pointing to that file so that the test results will show up in the build output.
More details about how to use this, please refer this similar tutorial with xUnit test: Execute and publish xUnit Tests results with .NET Core and VSTS
Note: For now VSTS/TFS does not support NUnit3 format. Source Link: Support NUnit2 format

How to publish Code coverage result back to TFS 2013

Scenario:
We're trying to enable code coverage in our TFS and so far the build summary result was successfully displaying code blocks covered as shown in picture below but the problem is every time we click Coverage Results link (arrow down in the picture) it doesn't shown the details of what has been covered and it display error in the browser even the test results In/Out folder have code coverage file in build server.
Setup:
MSTest Settings (Local.testsetting)
Test Run
Build Definition
Test Results
Build Summary:
After clicking Coverage Results:
Question : Why TFS 2013 project collection Coverage Results link (red arrow down) in build summary doesn't display code coverage details of what has been covered even the code coverage file was generated in build server TFS 2010? What do we missed in the settings to make it possible?
You need to
1). open the build definition, go to Process -> 3.Test -> Automated Test -> on the Add/Edit Test Run dialog, set the Options to be "Enable Code Coverage".
2). Select the .testsettings file in the build definition.
You can also to have a check on Ralph Jansen's reply in this question TFS 2013 - No Code Coverage Results
Moreover, also check could you open this code coverage link in web portal.
Update
add related screenshot

Display OpenCover results in TFS 2015 build Summary

I have generated my xml coverage file as part of CI build on the TFS server using vNext 2015 build definition. How would one display the results in the TFS 2015 summary ? Either using the xml report or the html generated using the ReportGenerator.
You need to convert the results produced by OpenCover to a format which can be parsed by TFS.
One way to do this would be to use the OpenCoverToCoberturaConverter NuGet package.
Once you have that, you can use the Publish Code Coverage Results build step.
I have described the whole process on my blog.
In “TFS 2015 - Update 2” this is possible by writing your own vsts extension (see here: https://www.visualstudio.com/en-us/docs/integrate/extensions/overview ).
I set up my own 'learning project' for building this as .vsix here: https://github.com/RobertK66/vsts-opencover.
My custom build step uses nunit3 console runner to execute tests under opencover.
I managed to upload the OpenCover xml result file as 'testrun-attachment' via REST-interface and got the pieces in place to show the summary values on both the build summary tab and on its own extended “build-results-view”.
Base for this first version were a lot of examples provided by MS on github: https://github.com/Microsoft/vsts-tasks and https://github.com/Microsoft/vsts-extension-samples
To get a first feeling what places on your TFS Web Portal can be extended/customized you can download and install this extension https://aha.gallery.vsassets.io/items?itemName=ms-samples.samples-contributions-guide from the Visual Studio Marketplace.
Hope this helps to get you started.
Currently, these customizations are not supported. You can't edit the displays in new build summary. However, you can customize Code Coverage Analysis.
You can submit it to User Voice site at:
http://visualstudio.uservoice.com/forums/121579-visual-studio
Instead of using OpenCover extension, it is very convenience for you to generate code coverage result and include it in the build summary page this way:
Select the Visual Studio Test step, check the Code Coverage Enabled option.
Then, the code coverage result shows on the build summary page:

TFS 2010 server build code coverage not shown in TFS "code coverage" dashboard chart

I am having a problem with the TFS SharePoint portals code coverage chart.
We have a .NET 4 solution that is being developed TDD, as a result we have pretty good code coverage, but as a quality check I want to monitor the code coverage rates as the project progresses.
To this end I have a test configuration (a .testsettings file in the solution) which is configured to instrument our soluton assemblies for code coverage and two team build definitions that use that test definition.
Both team builds (one is a CI trigger, the other a nightly shceduled trigger) work and produce code coverage figures
However despite sheduled team builds with code coverage the dashboard "code coverage" excel report always shows 0% coverage, in fact the excel spreadsheet containing the report does not contain any data. This is rather unexpected!
So my question boils down to what steps have I missed to make code coverage data from team builds show up in the TFS database used by the excel code coverage report?
As a side note the SSRS reports are also showing code coverage from the builds, it just seems to be the Excel spreadsheets that fail to see data.
UPDATE
It seems the problem is the filter "Is Build Verification Run" when this filter is removed I see data.
Specifically in my template (MSF for agile v5.0) the version of "code coverage" had a filter applied restricting output to just the "Other" value. Very odd.
When I am back in the office I'll try creating a new project based on the MSF Agile 5.0 tempate and see if this odd filter setting is part of it, or something I did in the past to this project!
I have verified this by creating a new project from the MSF For Agile Software Developmnet v5.0 template.
This turns out to be what I percieve as a bug in the "MSF For Agile Software Developmnet v5.0" template.
When the project is created the excel spreadhseet used for the "code coverage" chart in the dashboards has a filter on it restricting the data to just items whose origin is "other" this excludes code coverage data from a TFS build which has this value set to "true" in the cube.
Simply clearing the filter or including "true" in it resolves the issue and shows you your TFS build code coverage data.

TFS 2010 and VS 2010 Professional - viewing code coverage results of team build?

setup
TFS server 2010
Build server has visual studio premium edition
Dev machines have VS 2010 Professional
What's working
Project file is set up to capture code coverage results.
Team build configured to run on every commit.
Team build output shows overall code coverage aggregate numbers (75% covered etc)
What doesnt seem to be working
What I'd like to see is from developer machines, be able to see the coverage break up. From what I've read, seems like if I open a build run and in the build output, click the View test results link, it should show me the test results as well as the coverage results.
What's actually happening
When I click on View test results from the dev machines, I get some XSD errors
I've searched high and low and:
Can't find any other references to these errors - That suggests that I'm probably doing something silly. Any pointers?
I understand that VS premium or Ultimate edition is required for code coverage on the build server. But what I'd like to know is, do I need VS premium/Ultimate for viewing code coverage results of a team build too?
I guess yes you will need it, because the coverage viewer is part of the code coverage component which is only exist in VS Premium/Ultimate.

Resources