在运行dotnet测试-收集“代码覆盖率"时,如何设置自定义覆盖率结果文件路径? [英] How to set a custom coverage result file path when running dotnet test --collect "Code coverage"?

查看:87
本文介绍了在运行dotnet测试-收集“代码覆盖率"时,如何设置自定义覆盖率结果文件路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我按照

I followed the instructions on http://tdc1tfsapp01:8080/tfs/DefaultCollection/SharpTop/_packaging?_a=package&feed=dayforce&package=OrchardCore.Cms.Web&version=1.0.20098.7+1bcd36b1f8efd5484af49f8ec39c21060a64391e&protocolType=NuGet and it does produce a binary coverage result file and surfaces a link to it on the build.

但是,我想将其转换为Cobertura以便在构建本身上发布.这是一个相当复杂的过程,需要:

But, I want to convert it to Cobertura in order to publish on the build itself. It is a rather convoluted process, where one needs to:

  1. 下载 https://www.nuget.org/packages/Microsoft.CodeCoverage/包,然后在其中找到CodeCoverage.exe.
  2. 运行CodeCoverage.exe,将二进制coverage结果转换为相应的XML.
  3. 安装reportgenerator dotnet工具
  4. 运行reportgenerator工具将XML转换为Cobertura
  5. 最后我们可以发布到构建版本
  1. Download the https://www.nuget.org/packages/Microsoft.CodeCoverage/ package and locate CodeCoverage.exe inside.
  2. Run CodeCoverage.exe to convert the binary coverage result to the respective XML.
  3. Install the reportgenerator dotnet tool
  4. Run the reportgenerator tool to convert that XML to Cobertura
  5. Finally we can publish to the build

我的问题是我不知道在生成过程中将二进制结果放在何处.所以,我的问题是-我们可以自定义其位置吗?

My problem is that I do not know where the binary result is placed during the build. So, my question is - can we customize its location?

推荐答案

找到了它.需要完成三件事:

Found it. Three things need to be done:

  1. 关闭通过 DotNetCoreCLI @ 2 test 命令自动发布测试结果的功能.这样可以防止其注入自己的结果目录.
  2. -r 参数中传递您自己的目录.
  3. 添加明确的任务以发布测试结果.
  1. Turn off automatic publishing the test results from the DotNetCoreCLI@2 test command. This prevents it from injecting its own result directory.
  2. Pass your own directory in the -r parameter.
  3. Add an explicit task to publish the test results.

这是我运行测试的方式:

Here is how I run the tests:

- task: DotNetCoreCLI@2
  name: Test
  displayName: Test
  inputs:
    command: 'test'
    publishTestResults: false
    arguments: '-c Release --no-build -l trx -r "$(Build.StagingDirectory)\tests" --collect "Code coverage"'

覆盖范围结果为 $(Build.StagingDirectory)\ tests \< SOME GUID> \ *.coverage

这篇关于在运行dotnet测试-收集“代码覆盖率"时,如何设置自定义覆盖率结果文件路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆