Display OpenCover results in TFS 2015 build Summary - code-coverage

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:

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

Code Coverage Details within TFS

We are using the Team Foundation Server 2015 and our build task uses Report Generator for generating the Code Coverage view.
Now we are trying to get something similar without any third party libraries.
If I look at the build details, under the section "Code Coverage", I have two charts (Blocks and Lines) and beneath these a link "Download Code Coverage Results". And that's all. If I download the file and open it with Visual Studio I can see the details.
Is there any built-in way to generate a webpage or anything else which shows more details on the TFS itself?
There is no out of box feature for this, you can submit a feature request on VSTS User Voice.

TFSBuild - Saving OpenCover/ReportGenerator output for each tfs build on tfs2013

I'm currently trying to run custom code coverage using OpenCover and to generate output in easily readable format using Report Generator. The final output of these two applications is xml files.
I am running these applications using InvokeProcess activity in build definition to get their outputs but the output are currently present only in my build controller's Build binaries folder.(ex:C:\Builds\1\project_collection\build_definition\bin)
I want to save these files per build in some location and to retrieve them back when needed by clicking on a hyperlink present in Build summary similar to how built-in code coverage results are displayed in tfs build summary.
I tried this question but as you can see there is no correct answers listed there.
So how do I copy these output files to some remote location and refer them in my build summary to retrieve them?
Copy outputs to some remote location is similar to copy outputs to drop folder. You can simply specify the drop location in Build Definition--Build Defaults--Staging location. Check the screenshot below:
Refer the binaries in your build summary to retrieve them, you can add a new activity “WriteCustomSummaryInformation” to your build process template, which has several properties that allow you create a new Section and add text to that section. Check this blog for more information: http://blogs.msdn.com/b/jpricket/archive/2012/06/07/tfs11-rc-simple-build-summary-customization.aspx
As I also answered here Display OpenCover results in TFS 2015 build Summary, it is now possible to customize the build results in TFS 2015.
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”.

Import NCover or Instrumentation .Coverage files back into TFS 2010. so it shows up in the build summary report

My project has their tests using the NUnit framework, specifically 2.5.9. My build process currently creates nunit xml files, and then I convert them into .trx and publish them into TFS using mstest.exe. Now, I need to report back code coverage to TFS and show up in the build summary reports. I can create NCover results to xml, and was hoping I could include the NCover results into the NUnit xml and then convert it into the .TRX format and then import to TFS, but that's not going to work. But, it does look like the .TRX file can accept some code coverage information, according to the vsts.xsd, but I'm not sure if it is a file reference or other metrics.
I can also create .Coverage result files using Visual Instrumentation using an example from here: http://social.msdn.microsoft.com/Forums/en-US/vststest/thread/c7cd8dab-fed9-4fc4-9773-bdb047ad5958
So, I know I can publish unit test to TFS. The question is can I publish ncover or .coverage results BACK to TFS 2010?

integrate dotCover with TFS

Is there a tutorial somehwere or can somebody explain how to integrate dotCover with TFS? I want to run dotCover (probably the console runner?) as part of the team build process and would like to generate a report that is integrated in the TFS build report.
Running dotCover itself will be easy enough. Simply add an InvokeProcess activity to the build workflow and call the appropriate command line options. I've got a blog post showing how this is done (calling the VB6 compiler in my example) but it should show you what you need to do.
The hard part will be integrating a report into the TFS build report. All you'll really be able to do is slightly customise the log - see Ewald Hoffmans blog post (and series) on customising the build if you want to do this.

Resources