Adding Code Coverage of .NET Core XUnit project to VSTS build

天大地大妈咪最大 提交于 2020-01-06 02:45:50

问题


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.


回答1:


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

  1. Edit projects’ files (test and related project) to add DebugType property

for example:

<PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
    <IsPackable>false</IsPackable>
    <DebugType>Full</DebugType>
  </PropertyGroup>
  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 Studio\2017\Enterprise\Common7\IDE\Extensions\TestPlatform in Path to vstest.console.exe
  5. Check Code coverage enabled option
  6. Specify /framework:".NETCoreApp,Version=v2.0" in Other console options box


来源:https://stackoverflow.com/questions/50126183/adding-code-coverage-of-net-core-xunit-project-to-vsts-build

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!