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

时间:2019-05-09 21:59:36

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

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

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

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

关于我们指定路径的任何输入都会有用。

3 个答案:

答案 0 :(得分:4)

您基本上需要 Visual Studio Test Agent 来覆盖代码。

有2种可能的安装方式:

  • 选项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 :(得分:0)

更新构建代理并添加VS2017功能后,出现了类似的问题。

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

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

祝你好运

答案 2 :(得分:0)

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

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'