1

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.

enter image description here enter image description here

Boris Lipschitz
  • 9,236
  • 5
  • 53
  • 63
  • At the top of the page clearly the information is provided. – Lex Li May 02 '18 at 02:05
  • Thanks for downvoting. Do you refer to this link? https://github.com/Microsoft/vsts-tasks/blob/master/Tasks/VsTest/README.md – Boris Lipschitz May 02 '18 at 02:10
  • if yes, then point me how to enable code coverage for the .net core projects – Boris Lipschitz May 02 '18 at 02:12
  • Combining all keywords in the message, Google can easily lead you to threads like https://github.com/Microsoft/vstest/issues/579 Microsoft is still far from making everything ready. – Lex Li May 02 '18 at 02:31
  • Possible duplicate of [Code coverage and test results for dotnet core projects in VSTS](https://stackoverflow.com/questions/46159067/code-coverage-and-test-results-for-dotnet-core-projects-in-vsts) – Lex Li May 02 '18 at 02:31
  • I saw that link as well, however, my question is more relevant to XUnit rather than MSTests and besides there is no clear answer. In any case, there is no "At the top of the page clearly the information is provided". I'd prefer, someone knowledgeable from VSTS team answer my question – Boris Lipschitz May 02 '18 at 02:39
  • Do you solve this issue? – starian chen-MSFT May 16 '18 at 05:37

1 Answers1

2

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
starian chen-MSFT
  • 33,174
  • 2
  • 29
  • 53