question

AbhishekMukhia-9917 avatar image
0 Votes"
AbhishekMukhia-9917 asked AbhishekMukhia-9917 answered

Not able to generate ".coverage" report while running code coverage

I'm trying to run code coverage testing from command line using below commands:

vstest.console.exe CoverTest.dll /EnableCodeCoverage /ResultsDirectory:"C:\btstack\apps\projects\CoverageTest\TestResults\result_1.coverage"

And I'm seeing following error but test is able to proceed.

C:\btstack\apps\projects\CoverageTest\coverage_test>vstest.console.exe CoverTest.dll /EnableCodeCoverage /ResultsDirectory:"C:\btstack\apps\projects\CoverageTest\TestResults"
Microsoft (R) Test Execution Command Line Tool Version 16.3.0-preview-20190715-02
Copyright (c) Microsoft Corporation. All rights reserved.

Starting test execution, please wait...
Data collector 'Code Coverage' message: Data collector 'Code Coverage' failed to provide initialization information. Error: System.TypeInitializationException: The type initializer for 'Microsoft.VisualStudio.Diagnostics.Logging.ProfilerInterop' threw an exception. ---> Microsoft.VisualStudio.Diagnostics.Common.InvariantException: Failed to load IntelliTrace Profiler binary or failed to locate functions.

Diagnostic Messages Collected when attempting to load the profiler dll


Process is 64bit : True
ProfilerDLL : x64\Microsoft.IntelliTrace.Profiler.dll
Attempting to locate ProfilerDLL relative the executing assembly. Assembly: Microsoft.IntelliTrace.Core, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a. Path: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\Extensions\TestPlatform\x64\Microsoft.IntelliTrace.Profiler.dll
Attempting to locate ProfilerDLL relative to current process. Process: datacollector. Path: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\Extensions\TestPlatform\x64\Microsoft.IntelliTrace.Profiler.dll
Attempting to locate ProfilerDLL relative the IntelliTrace install directory: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\IntelliTrace\x64\Microsoft.IntelliTrace.Profiler.dll

===============================================================================
---> System.ComponentModel.Win32Exception: The system cannot find the path specified
--- End of inner exception stack trace ---
at Microsoft.VisualStudio.Diagnostics.Common.Check.Throw[XT](String message, Func`1 innerEx)
at Microsoft.VisualStudio.Diagnostics.Logging.ProfilerInterop.ThrowInvariantExceptionOnZeroPtr(IntPtr ptr, String message)
at Microsoft.VisualStudio.Diagnostics.Logging.ProfilerInterop.InitInterop()
at Microsoft.VisualStudio.Diagnostics.Logging.ProfilerInterop..cctor()
--- End of inner exception stack trace ---
at Microsoft.VisualStudio.Diagnostics.Logging.ProfilerInterop.get_InteropInterface()
at Microsoft.VisualStudio.Diagnostics.Logging.LoggingConfig.Publish()
at Microsoft.VisualStudio.TraceCollector.CommonDataCollector.InitiateCollection()
at Microsoft.VisualStudio.TraceCollector.CommonDataCollector.GetEnvironmentVariables()
at Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector.GetEnvironmentVariables()
at Microsoft.VisualStudio.TestPlatform.Common.DataCollector.DataCollectorInformation.SetTestExecutionEnvironmentVariables()
at Microsoft.VisualStudio.TestPlatform.Common.DataCollector.DataCollectionManager.GetEnvironmentVariables(Boolean& unloadedAnyCollector).
√ TestMethod1 [52s 608ms]

Test Run Failed.
Total tests: 1
Passed: 1
Total time: 53.8182 Seconds


After I stop the coverage I'm not able to see the report getting generated in the location given "C:\btstack\apps\projects\CoverageTest\TestResults\5b7e122b-d0bd-42ca-8592-f4f68ddf235a\ <Empty>"

Please let me know how to solve this.

Thanks!

vs-generalvs-testing
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

TianyuSun-MSFT avatar image
0 Votes"
TianyuSun-MSFT answered TianyuSun-MSFT edited

Hello Abhishek,

From the error message, it seems you are trying to use code coverage feature in Visual Studio 2019 community version(run with vstest.console.exe command line). Actually, the code coverage feature is available only in Visual Studio Enterprise edition, please refer to this document Code Coverage -- Requirements.

Please try to use VS Enterprise and use vstest.console.exe command line again to use code coverage feature.

Sincerely,
Tianyu


If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.





5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

AbhishekMukhia-9917 avatar image
0 Votes"
AbhishekMukhia-9917 answered

Hi Sun,

Thanks for the quick reply. I corrected the env variable with the correct path and now the report is getting generated.

C:\btstack\apps\projects\CoverageTest\coverage_test>vstest.console.exe CoverTest.dll /EnableCodeCoverage /ResultsDirectory:"C:\btstack\apps\projects\CoverageTest\TestResult"
Microsoft (R) Test Execution Command Line Tool Version 16.7.0
Copyright (c) Microsoft Corporation. All rights reserved.

Starting test execution, please wait...

A total of 1 test files matched the specified pattern.
√ TestMethod1 [3m 34s]

Attachments:
C:\btstack\apps\projects\CoverageTest\TestResult\07ae4a18-eef2-4119-8b2f-58cc3f028447\BTEM3_MININT-5594M8M 2020-09-25 13_56_10.coverage
Test Run Successful.
Total tests: 1
Passed: 1
Total time: 3.6511 Minutes

Thanks,
Abhishek M

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.