Azure DevOps 声纳云代码覆盖率问题

标签 azure azure-devops

在 azure devops 构建管道中,我有以下阶段。

  • 准备声纳云分析
  • dotnet 恢复
  • dotnet 构建
  • dotnet 测试
  • 不要发布
  • 复制测试文件..这用于将(*.trx *.xml)复制到相应的目录。
  • 运行代码分析
  • 发布质量门结果。

这里我的管道成功运行了测试,但没有提供代码覆盖率。代码覆盖率显示 0.00%

*.trx 文件正在所需路径上复制,我也尝试过使用 trx 文件的默认路径,但它在日志中给出以下消息。

错误消息

Post-processing started.
00:23:49.775  Property 'sonar.cs.vstest.reportsPaths' provided, skipping the search for TRX files in default folders.
00:23:49.995  Did not find any binary coverage files in the expected location.
00:23:49.995  Falling back on locating coverage files in the agent temp directory.
00:23:49.995  Searching for coverage files in D:\a\_temp
00:23:49.995  No coverage files found in the agent temp directory.
WARNING: The following projects do not have a valid ProjectGuid and were 
not built using a valid solution (.sln) thus will be skipped from 
analysis...
D:\a\1\s\Rost.API.Tests\Rost.API.Tests.csproj

我期望管道中的代码覆盖率,当前代码覆盖率显示 0.00%。

最佳答案

我可以向您确认几个问题吗?

  1. 您是否在命令行参数中添加了--collect“代码覆盖率” 选项? enter image description here

Code coverage can be collected by adding --collect "Code coverage" option to the command line arguments. This is currently only available on the Windows platform.

  • 如果在本地运行测试命令,代码覆盖率显示是否正确?
  • 顺便说一句,SonarQube 需要一个有效的项目 GUID,但核心项目实际上并不使用它。建议在测试项目文件中添加 ProjectGUID。

    <Project Sdk="Microsoft.NET.Sdk">
      <PropertyGroup>
        <TargetFramework>netstandard2.0</TargetFramework>
        <!-- SonarQube requires a valid Project GUID but Core projects dont actually use this -->
        <ProjectGuid>{9C99E491-F56E-4515-9F0B-D72A5207DB13}</ProjectGuid>
      </PropertyGroup>
    </Project>
    

    关于Azure DevOps 声纳云代码覆盖率问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56814444/

    相关文章:

    c# - 即使调用 Task.WaitAll(task),异步上传到 Azure 也不会阻塞

    azure - 将 Azure 分析服务连接到流量管理器和 Power BI

    azure - Azure WEBSITE_RUN_FROM_PACKAGE 真的意味着不解压 zip 存档吗?

    azure - 如何防止 Azure Devops 中的下一个发布管道在上一个发布管道完全完成之前启动?

    visual-studio-2013 - 是否可以从 Visual Studio Online (VS Team Services) 编辑我的代码?

    Azure 流分析唯一 EventId 属性为 NULL

    azure - 减少用于下载/导出的 Azure VM OS 磁盘的大小

    azure - 如何在安装了 Azure SDK 的 Visual Studio 中查找 Azure Blob 存储容器大小?

    azure-devops - 如何指向 Azure Pipelines 构建的引用存储库上的特定提交

    git - 我可以运行位于 Azure 数据工厂上的 git 存储库中的 SQL 脚本文件吗?