将 .NET Core XUnit 项目的代码覆盖率添加到 VSTS 构建 [英] Adding Code Coverage of .NET Core XUnit project to VSTS build

查看:29
本文介绍了将 .NET Core XUnit 项目的代码覆盖率添加到 VSTS 构建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将代码覆盖率指标添加到我们的 VSTS 构建中.解决方案是使用 XUnit 的 ASP.NET 核心.请告知步骤.

I'd like to add the code coverage metrics to our VSTS build. The solution is ASP.NET core with XUnit. Please advise on the steps.

推荐答案

请参考以下步骤为 .NET Core XUnit 测试启用代码覆盖:

Refer to these steps to enable code coverage for .NET Core XUnit test:

  1. 编辑项目文件(测试和相关项目)以添加 DebugType 属性

例如:

<PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
    <IsPackable>false</IsPackable>
    <DebugType>Full</DebugType>
  </PropertyGroup>

  1. 将 Microsoft.NET.Test.Sdk 包更新到最新版本(将版本值更改为 15.7.0)
  2. 添加 Visual Studio 测试任务以构建定义并指定测试程序集搜索文件夹
  3. 在选择测试平台使用部分中选择特定位置选项
  4. vstest.console.exe的路径中指定C:Program Files (x86)Microsoft Visual Studio2017EnterpriseCommon7IDEExtensionsTestPlatform
  5. 选中启用代码覆盖选项
  6. 其他控制台选项框中指定/framework:".NETCoreApp,Version=v2.0"
  1. Update Microsoft.NET.Test.Sdk package to latest version (change version value to 15.7.0)
  2. Add Visual Studio Test task to build definition and specify Test assemblies and Search folder
  3. Choose Specific location option in Select test platform using section
  4. Specify C:Program Files (x86)Microsoft Visual Studio2017EnterpriseCommon7IDEExtensionsTestPlatform in Path to vstest.console.exe
  5. Check Code coverage enabled option
  6. Specify /framework:".NETCoreApp,Version=v2.0" in Other console options box

这篇关于将 .NET Core XUnit 项目的代码覆盖率添加到 VSTS 构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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