3
votes

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.

2

2 Answers

2
votes

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.

4
votes

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.