我想将代码覆盖率指标添加到我们的VSTS构建中 . 解决方案是使用XUnit的ASP.NET核心 . 请告知步骤 .
请参阅以下步骤以启用.NET Core XUnit测试的代码覆盖:
例如:
<PropertyGroup> <TargetFramework>netcoreapp2.0</TargetFramework> <IsPackable>false</IsPackable> <DebugType>Full</DebugType> </PropertyGroup>
将Microsoft.NET.Test.Sdk包更新到最新版本(将版本值更改为15.7.0)
添加Visual Studio Test任务以构建定义并指定 Test assemblies 和 Search 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
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\Extensions\TestPlatform
检查 Code coverage enabled 选项
在 Other console options 框中指定 /framework:".NETCoreApp,Version=v2.0"
/framework:".NETCoreApp,Version=v2.0"
1 回答
请参阅以下步骤以启用.NET Core XUnit测试的代码覆盖:
例如:
将Microsoft.NET.Test.Sdk包更新到最新版本(将版本值更改为15.7.0)
添加Visual Studio Test任务以构建定义并指定 Test assemblies 和 Search 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"