unit-testing - 数据收集器“代码覆盖率”未能提供初始化信息
问题描述
我正在尝试使用构建管道创建代码覆盖率报告。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
这正在运行测试并且所有测试都通过了。但是我无法查看代码覆盖率报告。它创建的报告仅包含有关测试的信息
我们指定路径的任何输入都会很有用。
解决方案
您基本上需要用于代码覆盖率的Visual Studio 测试代理。
有两种可能的安装方法:
- 选项1
- 在构建服务器上安装
Agents for Visual Studio 2019
(从此处下载,请参阅Visual Studio 2019 的工具)。 - 在构建管道中编辑
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
- 将
Visual Studio test platform installer
构建任务添加到您的管道。(在测试任务之前添加此任务)。 - 在任务中,
Visual Studio Test Assemblies
您必须选择Installed by Tools Installer
Test platform version
- 将
注意:根据我的经验,我有一些测试在选项 1 中成功,但在选项 2 中失败。可惜我没有时间弄清楚为什么...
推荐阅读
- javascript - 如何从命令行或 javascript 打开 WhatsApp Mac
- r - 创建一个新的 var,其值应该是 r 中其他两个变量之间的平方差
- python - 从 2.7 升级到 3.6 时出现 python requests.post 错误
- ios - 在 Web 视图中从社交媒体下载视频
- python - 每次部署后强制重新安装 Python 包(Flask + Azure App Service)
- django - 应用程序无法读取 django 中的静态文件
- listview - 删除项目时列表不更新
- haskell - 如何在 Haskell 中导入 Math.X?
- python - 熊猫:asfreq 时间序列的奇怪行为
- string - Why commas and underscore is using in Golang. Explain the line 12 in the below code?