0

I have a unit test project, which only has one (1) test written against WebAPI project. When I run test coverage under Visual Studio 2015 Enterprise, it generates report with 9 lines covered. Which is correct.

However, when I run my coverage analysis with "vstest.console.exe" run analysis with "CodeCoverage.exe" which is under "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe", these generates .coverage and .coveragexml file with correct names, and when I open this file with VS 2015, it shows 0 lines of code covered.

I am targeting my same unit test .dll while I am running collect and analyze commands.

I am willing to use my reports agains sonarqube.

Am I missing something here?

Teoman shipahi
  • 47,454
  • 15
  • 134
  • 158
  • Are you sure you can just run the `CodeCoverage.exe` directly? According to [this MSDN page](https://msdn.microsoft.com/en-us/library/dd537628.aspx) you should run it through visual studio's UI, or you can run it like this: `vstest.console.exe MyTestAssembly.dll /EnableCodeCoverage`, meaning you use vstest.console.exe and not CodeCoverage.exe. – Quantic Jan 13 '17 at 22:02
  • @Quantic yes, I am following steps at http://stackoverflow.com/a/31810755/929902 – Teoman shipahi Jan 13 '17 at 22:07
  • @Quantic correction, you are right, I was actually using vstest.console.exe. But, result is same. Edited my question. – Teoman shipahi Jan 13 '17 at 22:11

1 Answers1

0

You can add "/Diag:" parameter when you run VSTest.Console.exe to show detailed log. One problem I have encountered that, if I run VSTest.Console.exe on my local, it works; but when I run VSTest.Console.exe in Jenkins, it has no coverage data. Here is an solution for running VSTest.Console.exe in Jenkins: VSTest.console.exe when run under Jenkins generate empty .coverage file.

I can't find any other useful information why running as a local account works in Jenkins. But when I use OpenCover, which may use similar way how to get coverage data with VSTest.Console. OpenCover requires "register profiler" in order to get coverage data. (https://github.com/OpenCover/opencover/blob/master/main/OpenCover.Documentation/Usage.rtf, search "register")

So, I think your issue may be caused by permission. Just have a try to run it in adminstrator. :)

Robin Ding
  • 741
  • 6
  • 9