首页 文章

将.NET Core XUnit项目的代码覆盖率添加到VSTS构建中

提问于
浏览
1

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

enter image description here

enter image description here

1 回答

  • 2

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

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

    例如:

    <PropertyGroup>
        <TargetFramework>netcoreapp2.0</TargetFramework>
        <IsPackable>false</IsPackable>
        <DebugType>Full</DebugType>
      </PropertyGroup>
    
    • 将Microsoft.NET.Test.Sdk包更新到最新版本(将版本值更改为15.7.0

    • 添加Visual Studio Test任务以构建定义并指定 Test assembliesSearch folder

    • 选择 Specific location option in Select test platform using 部分

    • Path to vstest.console.exe 中指定 C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\Extensions\TestPlatform

    • 检查 Code coverage enabled 选项

    • Other console options 框中指定 /framework:".NETCoreApp,Version=v2.0"

相关问题