数据收集器“代码覆盖率”未能提供初始化信息

Dev*_*Dev 13 unit-testing code-coverage build azure-pipelines

我正在尝试使用构建管道创建代码覆盖率报告。我Visual Studio code在构建管道中添加了类型任务并启用了代码覆盖率。

当构建被触发时。我越来越 :

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.
Run Code Online (Sandbox Code Playgroud)

---> System.ComponentModel.Win32Exception: The system cannot find the path specified
Run Code Online (Sandbox Code Playgroud)

这是运行测试并且所有测试都通过了。但是我无法查看代码覆盖率报告。它创建的报告仅包含有关测试的信息

我们在何处指定路径的任何输入都将很有用。

Flo*_*ris 21

您基本上需要Visual Studio 测试代理来实现代码覆盖。

有两种可能的安装方法:

  • 选项1
    1. Agents for Visual Studio 2019在构建服务器上安装(从此处下载,请参阅Visual Studio 2019 工具下的内容)。
    2. 在构建管道中编辑Visual Studio Test Assemblies任务。设置Select test platform usingSpecific location和设置Path to vstest.console.exe为例如C:\Program Files (x86)\Microsoft Visual Studio\2019\TestAgent\Common7\IDE\Extensions\TestPlatform\vstest.console.exe
  • 选项 2
    1. Visual Studio test platform installer构建任务添加到您的管道。(在测试任务之前添加此任务)。
    2. Visual Studio Test Assemblies任务中,您必须选择Installed by Tools Installer作为Test platform version

注意:根据我的经验,我有一些测试在选项 1 中成功,但在选项 2 中失败。可悲的是,我没有时间弄清楚为什么......


小智 -3

更新构建代理并添加 VS2017 功能后遇到类似的问题。

\n\n

下载(从https://www.opendll.com):microsoft.intellitrace.profiler.dll

\n\n

添加到文件夹 C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\Common7\\IDE\\Extensions\\TestPlatform\\x64\xe2\x80\x8b

\n\n

祝你好运

\n