.net - dotnet 测试无法找到友好名称“代码覆盖率”的数据收集器
问题描述
几个月前,当我们的项目还在 .NET 4.7.2 中时,我们曾经使用该Visual Studio Test
任务在 Azure DevOps Server 上运行单元测试。我们使用参数Test files
来指定哪些测试程序集需要运行并且Code Coverage
在那里工作得很好。
由于我们将项目迁移到 .NET 5.0,我们使用dotnet test
运行单元测试,现在Code Coverage
不再工作。
这是一个例子:
D:\test-2-1\_tool\dotnet\dotnet.exe test A.Test.dll B.Test.dll C.Test.dll --logger trx --results-directory D:\test-2-1\_temp --settings D:\test-2-1\5\s\.runsettings
Microsoft (R) Test Execution Command Line Tool Version 16.9.4
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
A total of 22 test files matched the specified pattern.
Data collection : Unable to find a datacollector with friendly name 'Code Coverage'.
Data collection : Could not find data collector 'Code Coverage'
内容.runsettings
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0" assemblyQualifiedName="Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector, Microsoft.VisualStudio.TraceCollector, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Configuration>
<CodeCoverage>
<ModulePaths>
<Include>
<ModulePath>{someRegexToLimitCodeCoverageToSpecificTestAssemblies}</ModulePath>
</Include>
</ModulePaths>
</CodeCoverage>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
在另一个较小的项目中,Code Coverage
仍然可以工作,但在这里我们指定应该测试哪些项目文件,而不是哪些编译的测试程序集。
这是现在要走的路吗?如果是,是否有可能通过指定测试程序集让它恢复工作?
提前致谢!
解决方案
推荐阅读
- java - 如何将此字符串“Mon Jan 01 00:00:00 AEDT 1990”转换为“1990101”?
- javascript - 当其中的输入具有焦点时,保持不活动的导航选项卡显示
- r - 如何将行中的每个元素除以相应的行值?
- linux - 无法重命名...没有这样的文件或目录
- c# - Linq method syntax to flatten xml nodes
- mysql - 相当于 mysql 正则表达式
- c++ - 特征 3.4 .reshape()
- jquery - Bootstrap 4 输入组和 jQuery Iris 颜色选择器目标选项
- python - 命名变量 Pandas 时出现意外的 SyntaxError
- php - 为什么 GuzzleHttp 客户端在 Laravel/Lumen 上使用它发出网络请求时会抛出 ClientException?