在 azure devops yaml 管道上使用 dotnet test 收集代码覆盖率
Collecting code coverage with dotnet test on azure devops yaml pipeline
我已经尽我所能来解决这个问题。
我有几个新的 .net core 3.1 或 .net standard 2 项目正在 Azure DevOps 服务上构建。我正在尝试为这些项目设置代码覆盖率,但一无所获。
当 运行 本地测试成功并创建代码覆盖率结果时。
3/24/20 3:39 [jgust] [portChangesFromAggregateRepo ≡]
>: dotnet test .\Common.UnitTests\ --collect:"Code coverage"
Test run for C:\src\bio\lib\Common\src\Common.UnitTests\bin\Debug\netcoreapp2.2\Common.UnitTests.dll(.NETCoreApp,Version=v2.2)
Microsoft (R) Test Execution Command Line Tool Version 16.3.0
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
Attachments:
C:\src\bio\lib\Common\src\Common.UnitTests\TestResultsf826e4-4a46-46dd-9fe5-7fd17b8cee1c20-03-24.15_40_28.coverage
Test Run Successful.
Total tests: 794
Passed: 794
Total time: 19.3390 Seconds
然而,运行这个项目在 Azure DevOps 上时,构建报告找不到收集器。
A total of 1 test files matched the specified pattern.
Data collection : Could not find data collector 'Code coverage'
Results File: d:\a\_temp\VssAdministrator_fv-az130_2020-03-24_20_53_07.trx
Test Run Successful.
Total tests: 794
Passed: 794
本次流水线任务如下:
是的,我在这里使用 windows 平台
关于为这些项目设置代码覆盖率收集,我遗漏了什么。
据我所知,我会全力以赴strait out of the book
此外,我正在使用所描述版本的软件包:
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
您应该在 Path to project(s)
中指定测试项目的 csproj 文件的路径,并确保测试项目参考 Microsoft.NET.Test.SDK 版本 15.8.0 或更高版本
虽然指定 .dll
文件的路径将使任务下的 dotnet test
命令能够 运行 测试,但它不允许收集覆盖率数据。该操作需要 .csproj
个文件的路径。
尝试使用
$(System.DefaultWorkingDirectory)\**\*${{ parameters.slnName }}*[T|t]est*.csproj
注意:本规范应使否定过时。
我已经尽我所能来解决这个问题。
我有几个新的 .net core 3.1 或 .net standard 2 项目正在 Azure DevOps 服务上构建。我正在尝试为这些项目设置代码覆盖率,但一无所获。
当 运行 本地测试成功并创建代码覆盖率结果时。
3/24/20 3:39 [jgust] [portChangesFromAggregateRepo ≡]
>: dotnet test .\Common.UnitTests\ --collect:"Code coverage"
Test run for C:\src\bio\lib\Common\src\Common.UnitTests\bin\Debug\netcoreapp2.2\Common.UnitTests.dll(.NETCoreApp,Version=v2.2)
Microsoft (R) Test Execution Command Line Tool Version 16.3.0
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
Attachments:
C:\src\bio\lib\Common\src\Common.UnitTests\TestResultsf826e4-4a46-46dd-9fe5-7fd17b8cee1c20-03-24.15_40_28.coverage
Test Run Successful.
Total tests: 794
Passed: 794
Total time: 19.3390 Seconds
然而,运行这个项目在 Azure DevOps 上时,构建报告找不到收集器。
A total of 1 test files matched the specified pattern.
Data collection : Could not find data collector 'Code coverage'
Results File: d:\a\_temp\VssAdministrator_fv-az130_2020-03-24_20_53_07.trx
Test Run Successful.
Total tests: 794
Passed: 794
本次流水线任务如下:
是的,我在这里使用 windows 平台
关于为这些项目设置代码覆盖率收集,我遗漏了什么。
据我所知,我会全力以赴strait out of the book
此外,我正在使用所描述版本的软件包:
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
您应该在 Path to project(s)
中指定测试项目的 csproj 文件的路径,并确保测试项目参考 Microsoft.NET.Test.SDK 版本 15.8.0 或更高版本
虽然指定 .dll
文件的路径将使任务下的 dotnet test
命令能够 运行 测试,但它不允许收集覆盖率数据。该操作需要 .csproj
个文件的路径。
尝试使用
$(System.DefaultWorkingDirectory)\**\*${{ parameters.slnName }}*[T|t]est*.csproj
注意:本规范应使否定过时。