【问题标题】:Data collector 'Code Coverage' failed to provide initialization information数据收集器“代码覆盖率”未能提供初始化信息
【发布时间】:2019-05-09 21:59:35
【问题描述】:

我正在尝试使用构建管道创建代码覆盖率报告。 我在构建管道中添加了typeVisual 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.

---> System.ComponentModel.Win32Exception: The system cannot find the path specified

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

我们指定路径的任何输入都是有用的。

【问题讨论】:

    标签: unit-testing build code-coverage azure-pipelines


    【解决方案1】:

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

    有两种可能的安装方式:

    • 选项 1
      1. 在构建服务器上安装Agents for Visual Studio 2019(从here 下载,参见Visual Studio 2019 工具)。
      2. 在构建管道中编辑Visual Studio Test Assemblies 任务。将Select test platform using 设置为Specific 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 中失败。遗憾的是我没有时间弄清楚为什么......

    【讨论】:

    • 选项 1 对我有用,选项 2 没有。谢谢!
    • 这应该是@Dev 接受的答案。选项 2 对我有用。
    • 很好的答案,这两个选项都对我有用 - 因为你的笔记,所以选择选项 1。
    【解决方案2】:

    我在配置构建容器时遇到了这个问题。

    1 为了安装 Visual Studio 2019 测试代理,我使用了Chocolatey

    1.2 安装 Chocolatey

    ​​>

    ENV ChocolateyUseWindowsCompression = false

    SHELL ["powershell.exe", "-ExecutionPolicy", "Bypass", "-Command"]
    RUN Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')); `
        [System.Environment]::SetEnvironmentVariable('PATH', "\"${env:PATH};%ALLUSERSPROFILE%\chocolatey\bin\"", 'Machine'); `
        choco feature enable -n allowGlobalConfirmation;
    

    1.2 用巧克力安装TestAgent

    RUN choco install visualstudio2019testagent -y
    

    2。编辑管道上的 VSTest 任务以使用特定位置。

    就我而言,我已将 VSBuildTools 安装到容器中。 VSTest 任务使用了 VSBuildTools vstest.console.exe,但执行需要一些位于 TestAgent 文件夹中的库。

    vstestLocationMethod: location
    vstestLocation: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\TestAgent\Common7\IDE\Extensions\TestPlatform\vstest.console.exe'
    

    【讨论】:

      【解决方案3】:

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

      已下载(来自https://www.opendll.com):microsoft.intellitrace.profiler.dll

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

      祝你好运

      【讨论】:

        猜你喜欢
        • 2015-01-12
        • 2022-11-16
        • 2017-02-20
        • 2014-08-19
        • 2017-12-15
        • 2021-09-26
        • 2019-02-25
        • 1970-01-01
        • 2018-01-11
        相关资源
        最近更新 更多