3

How do we enable code coverage and test results for .NET Core projects in VSTS?

Currently, it is not enabled for a .NET Core test task.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131

2 Answers2

4

This is half an answer (as I'm not a fan of code coverage).

First get dotnet test to output a trx file with the test results by passing the arguments -l trx

dotnet test

Then follow it up with the Publish Test Results task.

Here are the options I used:

publish test results

And you will get your results (P.S. It's a very simple app):

results

I'm guessing that a similar approach for code coverage can be attained.

DaveShaw
  • 52,123
  • 16
  • 112
  • 141
2

You can use Visual Studio Test task with /framework:".NETCoreApp,Version=v1.1" option to run .NET Core tests. (Specify vstest.console.exe path in a Visual Studio Test task: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\Extensions\TestPlatform)

An article about code coverage: Working with Code Coverage.

But there is the issue when uploading a coverage file: Publish VSTest: Skipping attachment as it exceeded the maximum allowed size or not available on disk.

On the other hand, you may get an empty-result-generated issue: Running code coverage from Visual Studio 2017 always results in "Empty results generated: No binaries were instrumented..".

To conclude, you can track the update of these issues, and try again after the issues have been fixed.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
starian chen-MSFT
  • 33,174
  • 2
  • 29
  • 53