Skip to content

Setting Up Test Coverage Profiling for C#

In order to use the Test Gap analysis, you’ll need to upload test coverage to Teamscale.

Uploading Coverage

If you already have existing coverage files have a look at Uploading Test Coverage to Teamscale.

Checkout our tutorial

In our general .NET TGA tutorial we outline the steps needed to set up TGA for a concrete sample project.

Visual Studio / TFS / MSTest Code Coverage

By default, TFS / Azure DevOps will make a .coverage file available to you if you enable code coverage collection in your builds. This guide shows you how to get that coverage to show up in Teamscale.

Since the original .coverage file is in binary format, it needs to be converted to XML before the upload to Teamscale happens. To perform the conversion, Microsoft's CodeCoverage.exe utility tool can be used. It is available as part of the Microsoft.CodeCoverage nuget package.

To convert your result.coverage file to result.xml, you can call the CodeCoverage.exe tool like this:

powershell
CodeCoverage.exe analyze /output:result.xml result.coverage

Afterwards, you can upload the resulting XML file to Teamscale. Please refer to the article on external uploads for details. In the REST API of the upload, specify VS_COVERAGE as value of the format parameter.

Merging Coverage

You can also use the above tool to merge multiple .coverage files into one .xml file, which will lead to faster upload processing.

Manual tests

Please refer to our tutorial for .NET applications.