Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable the code coverage view on VSTS?

My team uses VSTS with hosted agents and a Visual Studio Test build task to run all tests and produce code coverage. However the tab Code coverage remains empty afterwards, only showing a link to download the *.coverage file.

I actually expect the code coverage results to be shown, with tables and graphs which projects are tested and it's respective coverage.

We are using the Visual Studio Test build task to test net461 assemblies with the Code Coverage enabled checked.

Somewhat related are both this and this issue, but not entirely, because we are just using MSTest Framework with built-in Visual Studio Test build task, which (I understand) should also automatically publish the code coverage results.

Am I missing something to get this Code coverage view working? Thanks!!

enter image description here

like image 251
Herman Cordes Avatar asked May 29 '18 16:05

Herman Cordes


People also ask

How do I enable code coverage?

Go to Edit > Preferences > General and check Enable Code Coverage. This will enable access to the interface for the code coverage data that Mono exposes.

How do I enable analyze code coverage in Visual Studio 2022?

If you are using Visual Studio 2022 Enterprise, you can create a code coverage report in one of two ways: via the Test > Analyze Code Coverage for All Tests menu item, via the Analyze Code Coverage context menu item for tests in the Test Explorer window.

How do I enable Azure Devops code coverage?

As already explained in my previous article, the very first thing to do to add code coverage calculation is to install a NuGet package called Coverlet. This package must be installed in every test project in your Solution. So, running a simple dotnet add package coverlet. msbuild on your test projects is enough!

How do I view code coverage files?

Coverage in the Coverage tool windowThe Code Coverage tool windows appears right after you run a configuration with coverage and displays the coverage report. If you want to reopen the Coverage tool window, select Run | Show Code Coverage Data from the main menu, or press Ctrl+Alt+F6 .


1 Answers

In Code coverage Tab, you need to use Publish Code Coverage Results task to show tables and graphs there.

While for Publish Code Coverage Results task, it only supports Code Coverage data in Jacoco or Cobertura formats. So the result of the *.coverage file can not be shown by tables and graphs in Code coverage Tab.

More details, you can refer the blog Browse Code Coverage reports and the issue How to publish the code coverage result with a .coverage file.

like image 128
Marina Liu Avatar answered Nov 14 '22 16:11

Marina Liu