Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Code coverage and test results for .NET Core projects in VSTS

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.

like image 673
vignesh srinivasan Avatar asked Dec 07 '25 18:12

vignesh srinivasan


2 Answers

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.

like image 105
DaveShaw Avatar answered Dec 10 '25 17:12

DaveShaw


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.

like image 22
starian chen-MSFT Avatar answered Dec 10 '25 17:12

starian chen-MSFT



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!