11

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

Herman Cordes
  • 4,628
  • 9
  • 51
  • 87
  • What is the output of the `Visual Studio Test` task? Is code coverage shown on the Summary tab? – Daniel Mann May 29 '18 at 17:23
  • @DanielMann yes it is shown on the Summary tab in a small widget. What do you mean by output of the `Visual Studio Test` task? It's just executing all test succesfully. – Herman Cordes May 29 '18 at 18:12
  • @HermanCordes Can you show the detail build logs by setting system.debug as true? – Marina Liu May 30 '18 at 06:24
  • @MarinaLiu-MSFT Yes I can. I've just executed a build with that setting. However is there any specific part you're interested in? Because the build task log was just over 20k lines and the test step log, just over 42k lines. – Herman Cordes May 30 '18 at 07:34
  • @HermanCordes I tried to get the attachment type in the VS Test task , since I ignored you have already mentioned the attachment is .coverage. And I added an answer for the detail reason why the code coverage result is not shown as tables and graphs in Code coverage Tab. – Marina Liu May 31 '18 at 05:30

1 Answers1

11

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.

Marina Liu
  • 36,876
  • 5
  • 61
  • 74
  • 28
    VSTS doesn't support Microsoft's **own** code coverage format ? Are you kidding me ? – Alex Marshall Sep 12 '18 at 21:27
  • @AlexMarshall I'm wondering the same thing... Can we get some clarification on this? – reckface Oct 23 '18 at 15:19
  • 5
    Microsoft allows you to download the .Coverage file which you can open only with Visual Studio enterprise IDE, just to belittle you that you did not buy in to the premium label ... (says the Community edition user) – Daniël Tulp Dec 17 '18 at 14:43
  • 1
    @DaniëlTulp, the Enterprise requirement is not, or at least no longer, true. I don't know about Community, but VS Pro will open the .coverage file. However, you do have to do it a certain way. Open the solution that the coverage file is for, then use File -> Open... -> File... and select the .coverage file. It will open, analyze the results, and display them in the Code Coverage Results window. – Craig W. Feb 01 '19 at 15:52